This project is read-only.

Unrecognized Projections

Jan 25, 2011 at 7:52 PM

First, let me preface this with the statement that I am NOT a coordinate system guru.

I have several .prj files that originated from ESRI that Dot Spatial cannot instantiate (i.e. ProjectionInfo.ReadEsriString throws an exception).

The exception I get is "Failed to find projection to be rotated". 

1. This is a very misleading exception.  What really happened is there is no such ITransform in the list matching the PROJECTION name.  I would like to humbly suggest we change the exception for this particular error to something like "Projection not found" and it would really be informative if the projection name that it could not find would be specified as well.  If no one has any problems with this, I will attempt to make this change.

Below my numbered comments is the list of projections that could not be found. 

2. I think Miller_Cylindrical can be fixed easily.  It was actually in the list of ITransforms it was searching, but the name was "MillerCylindrical" instead of "Miller_Cylindrical".  If no one has any problems with this, I will change the name to "Miller_Cylindrical".

3. In the Transforms folder, I see 2 files of interest:



It seems the 2 above files need to somehow be added to the list of ITransforms.  I don't yet know how to get those added to the list, but I'm sure I can figure that out.  If no one has any problems with it, I will attempt to add in those transforms.

4.  That still leaves 8 projections unaccounted for.  Does anyone know how to add support for those?





List of unfound projections:


Hotine_Oblique_Mercator_Azimuth_Center (probably just need to add existing class to transform list)




Hammer_Aitoff (probably just need to add existing class to transform list)

Miller_Cylindrical (probably just need to fix the name to be correct).





Jan 25, 2011 at 10:00 PM

Hi Kyle, thanks for your work on this. 

I notice that the exception you are seeing is thrown as a


while you are calling a method named ReadEsriString(). Does it make sense for Proj4 related code to be throwing an exception while you are parsing an Esri string?


Also, I noticed that the Proj4 tests use a separate mechanism for displaying error strings. We might want to consolidate the ProjectionException code and GetErrorMsg() so that your changes will be reflected consistently across the code base.


Jan 27, 2011 at 6:45 PM

"Failed to find projection to be rotated" seems to be the wrong text for this problem.

Internally the error is named "Err37_ProjNotFound" so I would suggest changing the resource string in ProjectionMessages.resx to "Projection Not Found"

I am concerned that changing the name as kellison was talking about is not the safe solution, since the name it already has might also be a valid name. It appears that we already recognize multiple aliases for a projection if they are separated by semicolons in the projection's Name, so adding variants of how the name appears in the wild separated by semicolons seems to be the safe solution.

Jan 27, 2011 at 6:56 PM


Thanks, I should have seen the semi-colon split.  I will make both changes you suggest next time I post.

Thanks a bunch,


Jan 27, 2011 at 6:57 PM

The projection I am getting this error for is "Mercator_2SP" which was shortened from the full ESRI string:

PROJCS["unnamed",GEOGCS["unnamed ellipse",DATUM["unknown",SPHEROID["unnamed",6378137,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]

This is the contents of the .prj file MW4 writes for the "Google Mercator" projection used by most web-based tiled maps like Google Maps, Bing, and OpenStreetMap.

This projection is present in DotSpatial as the object DotSpatial.Projections.ProjectedCategories.World.WebMercator. Its Name is "WGS_1984_Web_Mercator_Auxiliary_Sphere".

I have not yet learned how the Projections library works, but I have learned:

1. There is a difference between ProjectionInfo objects like WebMercator and objects that inherit from DotSpatial.Projections.Transform, but I do not understand the difference yet

2. Only a hard-coded list of projections that inherit from DotSpatial.Projections.Transform get added to the list  _transforms that are recognized by DotSpatial.Projections.TransformManager.GetProjection where I am seeing the above exception thrown. WebMercator is not part of this group.

What do we need to do for my .prj file from MW4 to be recognized as the WebMercator projection, and for this to be a valid projection in GetProjection?

Jan 27, 2011 at 7:23 PM


This is an interesting link, but as usual with coordinate systems does not provide the complete answer we probably need to really implement, but it addresses your Mercator_2SP as well as some of the transforms I am missing as well...

This gives me a glimmer of hope.


Jan 28, 2011 at 6:14 PM

Great! Based on that link I found a fix for opening my shapefiles.

In DotSpatial.Projections/Transforms/Mercator.cs in public Mercator() I changed:

Name = "Mercator";


Name = "Mercator;Mercator_1SP;Mercator_2SP";

This makes DotSpatial read my shape files that have Mercator_2SP in their .prj files.

I am not sure whether this is the only thing that should be changed, or how to tell whether it recognizes my projection as the same as  DotSpatial.Projections.ProjectedCategories.World.WebMercator, but it is definitely a big step forward.

I am not up to date with DotSpatial code, so I will not check this in now.

Jan 28, 2011 at 6:53 PM

So, I'm looking at TransformManager.cs...

ITransform GetProj4(string name) returns a COPY of the transform that matches.
ITransform GetProjection(string name) returns the actual transform that matches.  Me thinks this is a bug.  It could mean that multiple clients are manipulating the same instance of a transform.  Can't be good.

Jan 28, 2011 at 7:14 PM

Hmm.. just make sure there is an access technique to directly work with the transform if you wanted to for some reason.  In other words, if a developer wants to interact with the pure set of transforms, they should be able to do so.  I think you are correct here, though, in that it probably should be returning a copy for this.



Feb 8, 2011 at 4:43 PM

I think I see another problem here.  I think it could be fixed in one of 2 places, so I'd like some recommendations on the best place for me to fix it:

In TransformManager.GetProjection(string name), it now returns a copy of the pure ITransform that matches (the fact that it is a copy is irrelevant for this discussion).  But if the matching ITransform is one that supports multiple names (e.g. "Mercator;Mercator1_SP;Mercator2_SP"), the Name field for the returned ITransform will still have the multiple names with the semi-colons.  I believe this is wrong.  I believe that after making the copy, we should set the Name to the requested name (e.g. "Mercator").  It is actually causing a problem for my code because somewhere later downstream, I save out the Esri Text which now contains the semi-colons in the PROJECTION tag, which is flat out wrong.

This could be fixed directly in the TransformManager.GetProjection() after making the copy, or I was wondering if we should do it in the Transform.Init(ProjectionInfo projectionInfo) method.  We could set the Name method there from the ProjectionInfo (I think...).  My first inclination is to fix in GetProjection() since that is really where the problem is introduced.


Feb 8, 2011 at 4:46 PM

After looking at the Transform.Init() method, we really don't have the info at that point, so I think the only place to fix this is in TransformManager.GetProjection().