Project WGS84 to British National Grid with Geometry Service

8449
10
09-01-2010 06:28 AM
RichardBetts
New Contributor
Hi Folks,

I'm trying to project an array of graphics in WGS84 (WKID:4326) to BNG (WKID:27700) using the geometry service.
The code works fine but the graphics I get back are all located about 100 metres to the west of where I would expect.

Im afraid I'm not too clued up on coordinate transformations. Can anyone tell me if I'm missing something?

Thanks

Richard
Tags (2)
0 Kudos
10 Replies
RichardBetts
New Contributor
Ok. It seems I need to switch Datums from GCS_WGS_1984(4326) to GCS_OSGB_1936(4277) before reprojecting to BNG(27700).

However, If I ask server to do this via the REST API, I get the exactly the values back as I send. 

http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/project?f=json&in...{%22geometryType%22%3A%22esriGeometryPoint%22%2C%22geometries%22%3A[{%22x%22%3A-4.21507141799085%2C%22y%22%3A57.4917322947405}]}

Can anyone help?
Thanks
0 Kudos
JimSibbald
Esri Contributor
One can project from 4326 to 27700 but not using the REST part of Geometry Server. The reason is that in order to move between datums one needs to use a Geodetic Datum Transformation such as ESPG::1314 or OSGB_1936_To_WGS_1984_Petroleum which the REST interface cannot accept.  I have put forward an enhancement request for this to be included.  The only way I managed to get the coordinate conversion to happen using Geometry Server was to use the SOAP interface.
0 Kudos
by Anonymous User
Not applicable
Just wondering if there is any update on this topic?
0 Kudos
TonyCollins
Occasional Contributor
Yea, I would like to know how this is going?
0 Kudos
IvanBespalov
Occasional Contributor III
Using ArcGIS server REST Api to project geometries u can input only Well-known ID's (wkid) - as Input/Output Spatial Refences presented here.

Using other Api's (Flex Api for expmple) you can create any own or exists Spatial Reference based on Well-Know Text (wkt) if ESRI Well-known ID (wkid) not exists.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags">
 
 <s:layout>
  <s:VerticalLayout paddingBottom="6"/>
 </s:layout>
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.Graphic;
   import com.esri.ags.SpatialReference;
   import com.esri.ags.events.GeometryServiceEvent;
   import com.esri.ags.events.MapMouseEvent;
   import com.esri.ags.geometry.Geometry;
   import com.esri.ags.geometry.MapPoint;
   
   import mx.controls.Alert;
   import mx.rpc.events.FaultEvent;
   import mx.utils.StringUtil;
   
   private var grGeometry:MapPoint = new MapPoint();
   
   /**
    * Listen map mouse down handler
    */
   protected function myMap_mapMouseDownHandler(event:MapMouseEvent):void
   {
    grGeometry = event.mapPoint;
    
    var geometriesToProject:Array = new Array();
    geometriesToProject.push(grGeometry);
    
     var wkid:Number = NaN; 
    /*  var wkid:Number = 1314;  */
    var wkt:String = "GEOGCS[\"OSGB 1936\",DATUM[\"OSGB_1936\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],TOWGS84[375,-111,431,0,0,0,0],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"DMSH\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9108\"]]";
    var projectionSR:SpatialReference = new SpatialReference(wkid, wkt);
    sampleGeometryService.project(geometriesToProject, projectionSR);
    
    var gr:Graphic = new Graphic(grGeometry);
    
    var grId:String = myGraphicsLayer.add(gr);
    
    trace(StringUtil.substitute("Graphic with id: {0} added.", grId));
   }
      
   /**
    * Listen geometry service project complete handler
    */
   protected function onProjectComplete(event:GeometryServiceEvent):void
   {
    var pt:MapPoint = (event.result as Array)[0] as MapPoint;
    trace(event.result.toString());
    Alert.show(StringUtil.substitute("From: x={0} \ny={1} \nSR={2}; \n\nTo: x={3} \ny={4} \nSR={5}", 
     grGeometry.x, 
     grGeometry.y, 
     grGeometry.spatialReference.toString(), 
     pt.x, 
     pt.y, 
     pt.spatialReference.toString()),
     "Projection result");
   }
   
   /**
    * Listen geometry service fault handeler
    */
   protected function onGeometryServiceFault(event:FaultEvent):void
   {
    trace(StringUtil.substitute("onGeometryServiceFault >> {0}", event.message));
    Alert.show(event.fault.message, "Projection failt");
   }
   
  ]]>
 </fx:Script>
 
 <fx:Declarations>
  <!-- Symbol for all point shapes -->
  <esri:SimpleMarkerSymbol id="sms"
         color="0x00FF00"
         size="12"
         style="{SimpleMarkerSymbol.STYLE_DIAMOND}"/>
  <esri:GeometryService id="sampleGeometryService" 
         url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer" 
         projectComplete="onProjectComplete(event)"
         fault="onGeometryServiceFault(event)"/>
 </fx:Declarations>
 
 <esri:Map id="myMap"
     mapMouseDown="myMap_mapMouseDownHandler(event)"
     level="3"
     wrapAround180="true">
  <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer"/>
  <esri:GraphicsLayer id="myGraphicsLayer" symbol="{sms}"/>
 </esri:Map>
</s:Application>


Tell me where I am wrong.
0 Kudos
BjornSvensson
Esri Regular Contributor
Using   ArcGIS server REST Api to project geometries u can input   only Well-known ID's (wkid) - as Input/Output Spatial Refences presented   here

Using other Api's (Flex Api for expmple) you can create   any own or exists Spatial Reference based on   Well-Know Text (wkt) if   ESRI Well-known ID (wkid) not exists. 

Tell me where I am wrong.


It's not a question of REST vs client-side APIs, but which version is being used. WKT is supported if the ArcGIS Server is 10.0 or later. (9.3 only supported WKID)

Doc: http://help.arcgis.com/en/webapi/flex/help/index.html#/System_requirements/017p0000000m000000/
0 Kudos
IvanBespalov
Occasional Contributor III
Bjorn, you right sampleserver2.arcgisonline.com/ (version 9.3)... returns fault.

ArcGIS Server REST API -> Using Spatial References:
  The REST API supports only well-known ID's. 


This JSON code is not WKID, but it is WKT of ESPG::1314:
{"wkt":"PROJCS[\"OSGB 1936 / British National Grid\",GEOGCS[\"OSGB36\",DATUM[\"OSGB36\",SPHEROID[\"Airy 1830\",6377563.396,299.3249646,AUTHORITY[\"EPSG\",\"7001\"]],TOWGS84[446.448,-125.157,542.06,0.1502,0.247,0.8421,-20.4894],AUTHORITY[\"EPSG\",\"6277\"]],PRIMEM[\"Greenwich\",0.0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.017453292519943295],AXIS[\"Geodetic latitude\",NORTH],AXIS[\"Geodetic longitude\",EAST],AUTHORITY[\"EPSG\",\"4277\"]],PROJECTION[\"Transverse_Mercator\",AUTHORITY[\"EPSG\",\"9807\"]],PARAMETER[\"central_meridian\",-2.0],PARAMETER[\"latitude_of_origin\",49.0],PARAMETER[\"scale_factor\",0.9996012717],PARAMETER[\"false_easting\",400000.0],PARAMETER[\"false_northing\",-100000.0],UNIT[\"m\",1.0],AXIS[\"Easting\",EAST],AXIS[\"Northing\",NORTH],AUTHORITY[\"EPSG\",\"27700\"]]"}


Question: is the projection in attached screenshot correct?
0 Kudos
JimSibbald
Esri Contributor
At Version 10.1 the REST Interface of Geometry Server is updated to include Datum Transformation.  If you need to have a transformation, which one does between WGS 1984 and British National Grid, then SOAP is the only way before the release of Version 10.1

Also at 10.1 the OSTN02 NTv2 Transformation is available as EPSG::5339, see attached.
0 Kudos
AndrzejBieniek
New Contributor III
Hi guys,
I have written an article to illustrate the problem.

http://osedok.wordpress.com/2012/01/17/conversion-of-british-national-grid-wkid27700-to-wgs84wkid432...


I have created as well a sample application using custom JS script to convert coordinates using the Helmert datum conversion - check it out...

Regards,
Andrzej
0 Kudos