This project is read-only.

ProjectionInfo

Oct 18, 2011 at 6:46 PM
Edited Oct 18, 2011 at 6:48 PM

I have found the following:

Dim myProj As ProjectionInfo

mystr="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"

myProj = ProjectionInfo.FromProj4String(myStr)

The coordinate system above is a projected coordinate system

Using the reverse to obtain the ESRI string:

   Dim myProjInfo As New ProjectionInfo

   myProjInfo = ProjectionInfo.FromEsriString(myProj.ToEsriString)

I am getting:

"PROJCS["",GEOGCS["",DATUM["",SPHEROID["WGS_1984",6378137,0]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]], PROJECTION["Mercator"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",0],PARAMETER["Standard_Parallel_1",0],PARAMETER["Scale_Factor",1],UNIT["Meter",1]]"

It appears as a projected coordinate system, but the GEOCS tag appears as well.

Is this correct?

I want to determine the coordinate system type (geographic or projected) by checking the ESRI string for PROJCS or GEOCS. In the example above both of these appear in the same ESRI string.

Does the IsLatLon method determine if it is a projected (false) or geographic (true) system?

If I used a geographic system:

+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs 

I get the correct:

"GEOGCS["",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223562997]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199433]]"

Terry

Oct 19, 2011 at 3:22 AM

I think this snippit reflects the way things were written. The ProjectionInfo code was written primarily without using proj4 string and ESRI string specification documents and might be incorrect.

        public bool TryParseEsriString(string esriString)
        {
            if (esriString == null)
            {
                return false;
            }

            if (!esriString.Contains("GEOGCS"))
            {
                return false;
            }

            if (esriString.Contains("PROJCS") == false)
            {
                GeographicInfo.ParseEsriString(esriString);
                IsLatLon = true;
                Transform = new LongLat();
                Transform.Init(this);
                return true;
            }

...

If you're an expert in this area, I encourage you to make a suggestion on how to fix the code, if needed.

Oct 19, 2011 at 9:17 AM

Hi Terry,

In the 'ESRI String' format:

if it's a geographic (unprojected) coordinate system, then it only contains GEOGCS.

if it's a projected coordinate system, then it contains both PROJCS and GEOGCS. The reason why a projected coordinate system still needs GEOGCS is because it's based on a specific datum / ellipsoid.

 

My suggestion is to check for the presence of PROJCS. If PROJCS is found, then it's a projected coordinate system. If PROJCS is not found, then it's a geographic system.

Jiri

Oct 19, 2011 at 2:15 PM

That confirms what I was thinking. Thanks Jiri.