Checking a SpatialReference is WGS84

750
2
Jump to solution
03-30-2020 11:23 AM
AbelPerez
Occasional Contributor III

What is the proper way to check if a SpatialReference is WGS84?

I have tried

Dim sr as SpatialReference = MapView.Active.Camera.SpatialReference

If sr = SpatialReferences.WGS84 Then IsWGS4=True 'doesnt work

If sr Is SpatialReferences.WGS84 Then IsWGS4=True 'doesnt work

If If sr.Name = "GCS_WGS_1984" Then IsWGS4=True 'this works

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnnetteLocke
Esri Contributor

The easiest way is to check the well-known id.

if (sr.Wkid == SpatialReferences.WGS84.Wkid)

  IsWGS84 = true;

or you could use the hard-coded wkid = 4326. 

if (sr.Wkid == 4326) ... but occasionally these wkids are changed by EPSG so the first way is safer.

View solution in original post

0 Kudos
2 Replies
AnnetteLocke
Esri Contributor

The easiest way is to check the well-known id.

if (sr.Wkid == SpatialReferences.WGS84.Wkid)

  IsWGS84 = true;

or you could use the hard-coded wkid = 4326. 

if (sr.Wkid == 4326) ... but occasionally these wkids are changed by EPSG so the first way is safer.

0 Kudos
AbelPerez
Occasional Contributor III

Thanks for the tip.

0 Kudos