1

I am querying a map service for a GeoJson format and the GeoJson FeatureCollection geometries from ArcGIS Server 10.4.1 do not include the bbox property.

Is it possible to configure this, either as an ArcGIS server configuration or in the query request i

I am getting this:

{
    "type": "Polygon",
    "coordinates": [[[...]]
}

But want this:

{
    "type": "Polygon",
    "bbox": [...],
    "coordinates": [[[...]]]
}

Further clarification:

The query request itself has no spatial conditions. Basically, I'm looking to return the same format as the PostGIS ST_AsGeoJSON http://postgis.net/docs/manual-2.2/ST_AsGeoJSON.html with option 1.

1

If I understand correctly what you're asking, instead of querying using a bbox parameter, specify an envelope as in:

&geometry=-13656000%2C5704000%2C-13657000%2C5705000&geometryType=esriGeometryEnvelope

For example, the above equivalent to a bounding box defined by xmin,ymin,xmax,ymax (-13656000,5704000,-13657000,5705000), can be used to query an Esri feature service with the URL:

http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer/0//query?where=&objectIds=&time=&geometry=-13656000%2C5704000%2C-13657000%2C5705000&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Foot&returnGeodetic=false&outFields=&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=pgeojson

Conversely, to get the return as bbox (extent) from, say, the features returned from the above URL (feature oids 1,2,3,4,6,7,12), I can make the request with the param returnExtentOnly=true:

http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer/0//query?where=&objectIds=1%2C2%2C3%2C4%2C6%2C7%2C12&time=&geometry=&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&returnExtentOnly=true&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=pgeojson

This returns a similar but not exact bbox as I fed in with the first URL:

{ "type" : "FeatureCollection", "crs" : { "type" : "name", "properties" : { "name" : "EPSG:3857" } }, "bbox" : [-13656995.4512404, 5704009.15428216, -13656064.7915769, 5704792.01226095], "features" : [] }

Of course the bbox doesn't need to exactly match to select the exact same features (in this case, it depends on how points are dispersed); however, feeding in the last resultant bbox as a spatial query envelope should serve more adequately as a check - it 'should' return the same feature oids:

http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer/0//query?where=&objectIds=&time=&geometry=+-13656995.4512404%2C5704009.15428216%2C-13656064.7915769%2C5704792.01226095&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.0&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=true&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=pgeojson

...and it does NOT - oid 3 drops out presumably because it is on the edge of the bbox:

{ "type" : "FeatureCollection", "properties" : { "objectIdFieldName" : "FID", "objectIds" : [ 1, 2, 4, 6, 7, 12 ] }, "features" : [] }

If I adjust the distance parameter ever so slightly, oid 3 is 'recovered' - I was playing with this a bit and used a minuscule value of 0.000008 meters:

http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer/0//query?where=&objectIds=&time=&geometry=+-13656995.4512404%2C5704009.15428216%2C-13656064.7915769%2C5704792.01226095&geometryType=esriGeometryEnvelope&inSR=&spatialRel=esriSpatialRelIntersects&resultType=none&distance=0.000008&units=esriSRUnit_Meter&returnGeodetic=false&outFields=&returnGeometry=true&multipatchOption=xyFootprint&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=true&returnCountOnly=false&returnExtentOnly=false&returnDistinctValues=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&resultOffset=&resultRecordCount=&returnZ=false&returnM=false&quantizationParameters=&sqlFormat=none&f=pgeojson

This is the confirmed result:

{ "type" : "FeatureCollection", "properties" : { "objectIdFieldName" : "FID", "objectIds" : [ 1, 2, 3, 4, 6, 7, 12 ] }, "features" : [] }

  • No, I'm trying to get the bbox of the geometry in the GeoJson response. The query request itself has no spatial conditions. Basically, I'm looking to return the same format as the PostGIS ST_AsGeoJSON postgis.net/docs/manual-2.2/ST_AsGeoJSON.html with option 1. – Jay Cummins Jan 28 '17 at 11:49
  • Understood, see my edits above, Jay. – T. Wayne Whitley Jan 28 '17 at 22:17
  • My question was for ArcGIS Server configuration but it appears that this isn't possible at 10.4.x. So I'm accepting this answer since it is a work-around (but certainly not the only one). – Jay Cummins Feb 6 '17 at 18:57
0

For ArcServer 10.41 & from ArcGISOnline Open Data, the method to do this is succinctly explained here: https://github.com/Esri/terraformer-arcgis-parser/issues/44 from Esri.

  • Can you be more specific? I don't see anything in that thread or the REST API link resources.arcgis.com/en/help/arcgis-rest-api/index.html#/… that speaks to configuring the GeoJSON format that is produced when the geojson parameter is set. – Jay Cummins Feb 6 '17 at 18:32
  • If you're saying that what you're missing is the bbox property/values returned within the geojson object from ArcServer, I do not know if that is possible at this time/at 10.41 or how to go about including that in the returned geojson object. That said, I'd add to that GitHub issue thread. John Gravois or someone else on the JS API team monitor GitHub closely, not sure how closely they monitor GIS SE. – Shawn Goulet Feb 6 '17 at 18:44
  • @jay-cummins, In addition to the work around described by t-wayne-whitely, another work around approach to get the bbox is by using terraformer with: var boundingBox = polygon.bbox(); // returns the geojson bounding box for an object. – Shawn Goulet Feb 7 '17 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.