You can use DotSpatial to reprogram to long. If you are reading in a shapefile, and the .prj file exists so that the projection is known, then you only need:
Shapefile sf = Shapefile.OpenFile("C:\myshapefile.shp"); sf.Reproject(DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984);
If, however, the .prj file is missing, you need to first define the projection as:
Shapefile sf = Shapefile.OpenFile("C:\myshapefile.shp"); sf.Projection = DotSpatial.Projections.KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone32N; sf.Reproject(DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984);
But if, for example, you donβt have a shapefile, and you just want to reprogram the coordinate set from one projector to another, you can directly use the reprogramming utility:
// interleaved x and y values, so like x1, y1, x2, y2 etc. double[] xy = new double[]{456874.625438354,5145767.7929015327}; // z values if any. Typically this is just 0. double[] z = new double[]{0}; // Source projection information. ProjectionInfo source = DotSpatial.Projections.KnownCoordinateSystems.Projected.UtmWgs1984.WGS1984UTMZone32N; // Destination projection information. ProjectionInfo dest = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984; // Call the projection utility. DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, source, dest, 0, 1);
This last method uses an array such that the projection module can work without a direct reference to the data module.
source share