Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Updated Wiki: ReadESRIPrjFiles

$
0
0

Sample code to project a point using the ESRI Projection File
This sample is now out of date, but may be used as a starting point.

VB.Net Sample Code

Imports DotSpatial.Projections

'Sample code that will conduct a reprojection by reading in the ESRI.prj filePrivateSub btnProjection_Click(sender AsObject, e As EventArgs)
       'declares a new ProjectionInfo for the startind and ending coordinate systems'sets the start GCS to WGS_1984Dim pStart As ProjectionInfo = KnownCoordinateSystems.Geographic.World.WGS1984
        'reads the end coordinate system from the ESRI .prj file
Dim pESRIEnd As ProjectionInfo = ProjectionInfo.Open("C:\Program Files\ArcGIS\Coordinate Systems\Projected Coordinate Systems\UTM\WGS 1984\WGS 1984 UTM Zone 1N.prj") 'declares the point(s) that will be reprojectedDim xy AsDouble() = NewDouble(1) {} Dim z AsDouble() = NewDouble(0) {} 'calls the reprojection function Reproject.ReprojectPoints(xy, z, pStart, pESRIEnd, 0, 1) MessageBox.Show("Points have been projected successfully.") EndSub



C# Sample Code

using DotSpatial.Projections;

        //Sample code that will conduct a reprojection by reading in the ESRI.prj fileprivatevoid btnProjection_Click(object sender, EventArgs e)
        {
            //declares a new ProjectionInfo for the startind and ending coordinate systems//sets the start GCS to WGS_1984
            ProjectionInfo pStart = KnownCoordinateSystems.Geographic.World.WGS1984;
            ProjectionInfo pESRIEnd = ProjectionInfo.Open("C:\\Program Files\\ArcGIS\\Coordinate Systems\\Projected Coordinate Systems\\UTM\\WGS 1984\\WGS 1984 UTM Zone 1N.prj"); 
//declares the point(s) that will be reprojected
double[] xy = newdouble[2];
double[] z = newdouble[1];
//calls the reprojection function
Reproject.ReprojectPoints(xy, z, pStart, pESRIEnd, 0, 1);
MessageBox.Show("Points have been projected successfully.");
}

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>