Sample code that demonstrates how to read a prog4 string and then project a point
C# Code
using DotSpatial.Projections; //Code that allows the user to input a Proj4 string and reproject a WGS 1984 GCS to a Proj4 PCSprivatevoid btnProjection_Click(object sender, EventArgs e) { //Declares a new ProjectionInfo and sets it to GCS_WGS_1984 ProjectionInfo pStart = new ProjectionInfo(); pStart = KnownCoordinateSystems.Geographic.World.WGS1984; //Declares a new ProjectionInfo and allows the user to directly input a Proj4 sring ProjectionInfo pEnd = ProjectionInfo.FromEsriString("+proj=aea +lat_1=20 +lat_2=-23 +lat_0=0 +lon_0=25 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs "); //Declares the point to be project, starts out as 0,0double[] xy = newdouble[2]; double[] z = newdouble[1]; //calls the reproject function and reprojects the points Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1); MessageBox.Show("Reprojection is compelte."); }
VB.net Code
Imports DotSpatial.Projections 'Code that allows the user to input a Proj4 string and reproject a WGS 1984 GCS to a Proj4 PCSPrivateSub btnProjection_Click(sender AsObject, e As EventArgs) 'Declares a new ProjectionInfo and sets it to GCS_WGS_1984Dim pStart AsNew ProjectionInfo() pStart = KnownCoordinateSystems.Geographic.World.WGS1984 'Declares a new ProjectionInfo and allows the user to directly input a Proj4 sringDim pEnd As ProjectionInfo = ProjectionInfo.FromEsriString("+proj=aea +lat_1=20 +lat_2=-23 +lat_0=0 +lon_0=25 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ") 'Declares the point to be project, starts out as 0,0Dim xy AsDouble() = NewDouble(1) {} Dim z AsDouble() = NewDouble(0) {} 'calls the reproject function and reprojects the points Reproject.ReprojectPoints(xy, z, pStart, pEnd, 0, 1) MessageBox.Show("Reprojection is compelte.") EndSub