ThinkGeo.com    |     Documentation    |     Premium Support

Problem with ConvertPrjToProj4

I’m using the attached shapefile and trying to load the projection based on the prj. However, when I use Proj4Projection.ConverPrjToProj4(path) it returns an empty string. I checked the prj file and it seems to have everything in there, so I must be missing something. Here is the code I’m using. The shapefile is attached. Thanks for any help you can provide. 




featureLayer = new ShapeFileFeatureLayer(layer.Path);
                    string prjPath = System.IO.Path.ChangeExtension(layer.Path, “prj”);
                    Proj4Projection projection = new Proj4Projection();
                    projection.InternalProjectionParametersString = Proj4Projection.ConvertPrjToProj4(prjPath);
                    projection.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
                     
                    if (!string.IsNullOrWhiteSpace(projection.InternalProjectionParametersString) &&
                        !string.IsNullOrWhiteSpace(projection.ExternalProjectionParametersString) && 
                        projection.InternalProjectionParametersString != projection.ExternalProjectionParametersString)
                    {
                        featureLayer.FeatureSource.Projection = projection;
                    }


Streets.zip (1.47 MB)

Hi Clay, 
  
 Please change your code to this: 
  
 projection.InternalProjectionParametersString = Proj4Projection.ConvertPrjToProj4(System.IO.File.ReadAllText(prjPath)); 
  
 That should works for you. 
  
 Regards, 
  
 Don

That got it. Thanks, Don.

Hi Clay, 
  
 Any other questions, please feel free to let know. 
 Thanks, 
 Troy