This project is read-only.

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 file
Private Sub btnProjection_Click(sender As Object, e As EventArgs)
       'declares a new ProjectionInfo for the startind and ending coordinate systems
        'sets the start GCS to WGS_1984
        Dim 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 reprojected Dim xy As Double() = New Double(1) {} Dim z As Double() = New Double(0) {} 'calls the reprojection function Reproject.ReprojectPoints(xy, z, pStart, pESRIEnd, 0, 1) MessageBox.Show("Points have been projected successfully.") End Sub



C# Sample Code

using DotSpatial.Projections;

        //Sample code that will conduct a reprojection by reading in the ESRI.prj file
        private void 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 = new double[2];
double[] z = new double[1];
//calls the reprojection function
Reproject.ReprojectPoints(xy, z, pStart, pESRIEnd, 0, 1);
MessageBox.Show("Points have been projected successfully.");
}

Last edited Feb 15, 2016 at 10:05 AM by jany_, version 12