Sunday 22 January 2017

Extracting lat/long from screen when using British National Grid projection in ArcGIS Desktop?


Using ArcGIS Desktop 10.0, is it possible to click anywhere on the map (projected to British National Grid), but return the coordinates in WGS84 lat long?



Answer



To do this with arcobjects you could implement ITool. If using 10.0, you might find it easier to create a tool add-in.



In ITool.OnMouseDown take the x and y and convert it to an IPoint using IDisplayTransformation.ToMapPoint.


I'm not that familiar the the British National Grid, but it appears that a datum transformation is required when projecting to WGS84.


So, use ISpatialReferenceFactory.CreateGeoTransformation to create the appropriate datum transformation, and ISpatialReferenceFactory.CreateGeographicCoordinateSystem to create the target (WGS84) spatial reference.


Finally, cast the point into IGeometry5 and call ProjectEx, passing the target spatial reference and the geotransformation. IPoint.X and IPoint.Y should then represent longitude and latitude of the point where the user clicked.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...