Select to view content in your preferred language

How to project a MapPoint to WGS1984?

2928
6
Jump to solution
11-16-2012 12:57 PM
Labels (1)
GeorgeFaraj
Frequent Contributor
I need to project a MapPoint obtained by using Map.ScreenToMap into WGS1984. What would be the quickest way to do this?

With the ArcObjects SDK I would just pass the new SpatialReference into IPoint.Project and it would project it correctly from any source spatial reference. That method doesn't exist any more apparently.

Thanks,
George
0 Kudos
1 Solution

Accepted Solutions
ClayGinn2
New Contributor
I was able to do something similar using the following code.
 private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");                  private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point)         {             ESRI.ArcGIS.Client.Geometry.MapPoint result = null;                  System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326));                 result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;             }              return result;         }


I'm converting to GCS_WGS_1984 to display coordinates on mouse over. You would have to replace 4326 with the WKID for what you're converting to.

The main issue that I have with this is that it is using an online service which I won't always have access to. I'm trying to find a way to do this locally if possible.

View solution in original post

0 Kudos
6 Replies
GeorgeFaraj
Frequent Contributor
See here:

http://resources.arcgis.com/en/help/runtime-wpf/apiref/index.html?esri.arcgis.client~esri.arcgis.cli...


That seems to assume that I have a WebMercator source coordinate system. I want to project any coordinate system to WGS1984. Is this possible?

Trying WebMercator.ToGeographic throws an exception: "Invalid spatial reference." I guess because my source spatial reference is NOT Web Mercator.

Any other ideas?
0 Kudos
RonVincent
Deactivated User
That seems to assume that I have a WebMercator source coordinate system. I want to project any coordinate system to WGS1984. Is this possible?

Trying WebMercator.ToGeographic throws an exception: "Invalid spatial reference." I guess because my source spatial reference is NOT Web Mercator.

Any other ideas?


I don't think it is. The map is by default in WebMercator unless you create a tile package or map package in another projection like WGS84.
0 Kudos
ClayGinn2
New Contributor
I was able to do something similar using the following code.
 private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");                  private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point)         {             ESRI.ArcGIS.Client.Geometry.MapPoint result = null;                  System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326));                 result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;             }              return result;         }


I'm converting to GCS_WGS_1984 to display coordinates on mouse over. You would have to replace 4326 with the WKID for what you're converting to.

The main issue that I have with this is that it is using an online service which I won't always have access to. I'm trying to find a way to do this locally if possible.
0 Kudos
KevinChan
Emerging Contributor
I was able to do something similar using the following code.

private ESRI.ArcGIS.Client.Tasks.GeometryService _geometryService = new ESRI.ArcGIS.Client.Tasks.GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
                
private ESRI.ArcGIS.Client.Geometry.MapPoint ConvertToWgsCoordinates(ESRI.ArcGIS.Client.Geometry.MapPoint point)
        {
            ESRI.ArcGIS.Client.Geometry.MapPoint result = null;

                System.Collections.Generic.IList<Graphic> graphics = this._geometryService.Project(new System.Collections.Generic.List<Graphic>() { new Graphic() { Geometry = point } }, new ESRI.ArcGIS.Client.Geometry.SpatialReference(4326));
                result = graphics[0].Geometry as ESRI.ArcGIS.Client.Geometry.MapPoint;
            }

            return result;
        }


I'm converting to GCS_WGS_1984 to display coordinates on mouse over. You would have to replace 4326 with the WKID for what you're converting to.

The main issue that I have with this is that it is using an online service which I won't always have access to. I'm trying to find a way to do this locally if possible.


This method seems to use the GeometryService class, and it seems to require the service on the esri's server, is there a way to do it locally, just in case client somehow doesn't have internet connection?

Thanks,
Kev84
0 Kudos
TalShapiro
Emerging Contributor
0 Kudos