Select to view content in your preferred language

Can RESTful API return latitude and longitude?

1896
2
Jump to solution
10-26-2018 01:46 AM
LarsFagerbakke
New Contributor III

Is it possible that instead, or in addition to, of returning the spatial coordinates could return latitude and longitude? I got this simple result from my query

{     "objectIdFieldName": "OBJECTID",     "globalIdFieldName": "",     "hasZ": false,     "geometryType": "esriGeometryPoint",     "spatialReference": {         "latestWkid": 32632,         "wkid": 32632     },     "fields": [         {             "name": "OBJECTID",             "type": "esriFieldTypeOID",             "alias": "ID"         }     ],     "features": [         {             "geometry": {                 "x": 283130.435,                 "y": 6571673.844             },             "attributes": {                 "OBJECTID": 4294824             }         },
0 Kudos
1 Solution

Accepted Solutions
RandyBurton
MVP Alum

When you query your feature specifiy:

        "outSR" : "4326", # 4326 = WGS 1984 lat/lon

See 'outSR' in the request parameters section of this page: Query (Feature Service).

You can also convert after retrieving your data using projectAs:

# 4326: WGS 1984 (Lat/Lon) 
# 32631: WGS 84 / UTM zone 31N 

ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(32632)).projectAs(arcpy.SpatialReference(4326))  

print ptGeometry.firstPoint.X, ptGeometry.firstPoint.Y‍‍‍‍‍‍‍‍

View solution in original post

2 Replies
RandyBurton
MVP Alum

When you query your feature specifiy:

        "outSR" : "4326", # 4326 = WGS 1984 lat/lon

See 'outSR' in the request parameters section of this page: Query (Feature Service).

You can also convert after retrieving your data using projectAs:

# 4326: WGS 1984 (Lat/Lon) 
# 32631: WGS 84 / UTM zone 31N 

ptGeometry = arcpy.PointGeometry(arcpy.Point(x,y),arcpy.SpatialReference(32632)).projectAs(arcpy.SpatialReference(4326))  

print ptGeometry.firstPoint.X, ptGeometry.firstPoint.Y‍‍‍‍‍‍‍‍
LarsFagerbakke
New Contributor III

Super, thanks!

0 Kudos