1

I have lat,long values that I need to convert to x,y in a custom Lambert Conformal Conic projection defined as +units=m +a=6371229 +b=6371229 +x_0=0 +y_0=0 +proj=lcc +lon_0=0 +lat_2=25.0 +lat_1=25.0 +lat_0=25.0. I'm trying to use Dotspatial.Projections library in C# to basically replicate a process I have working in Python using Pyproj. Unfortunately, my C# function produces 0,0 which is not correct. Please find below the code:

string pj_grid_str = @"+units=m +a=6371229 +b=6371229 +proj=lcc +x_0=0 +y_0=0 +lon_0=0 +lat_2=25.0 +lat_1=25.0 +lat_0=25.0";
string pj_latlon_str = @"+proj=latlong +a=6371229 +b=6371229";
var pj_grid = DotSpatial.Projections.ProjectionInfo.FromProj4String(pj_grid_str);
var pj_latlon = DotSpatial.Projections.ProjectionInfo.FromProj4String(pj_latlon_str);

double[] ll = { -114.0, 51.0 };
double[] z = { 0.0 };

DotSpatial.Projections.Reproject.ReprojectPoints(ll, z, pj_latlon, pj_grid, 0, 1);

 System.Console.WriteLine(ll[0].ToString() + "," + ll[1].ToString());   //produces "0,0" no matter what input I provide
// should produce "-1489098.19006,3107428.30237"

Again, using a similar procedure in Pyproj with the same proj.4 strings works just fine and produces correct results.

P.S. I seem to have found a way to do this using Proj.NET library, but am still puzzled as to why Dotspatial can't do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.