Query Extents does not work - ArcGIS Python API

475
1
01-07-2019 04:35 PM
FMGLGIS
New Contributor III

Im trying to use the ArcGIS Python API to query a few results and gather the extent, I can query the results fine but as soon as I try to extract the extent I retrieve empty results.

Using one of the samples servers, heres my code:

import arcgis.gis gis = GIS()  t = 'https://sampleserver6.arcgisonline.com/arcgis/rest/services/DamageAssessment/FeatureServer/0' layer = FeatureLayer(t, gis)  results = layer.query(where='1=1', return_extent_only=True) 

After I print results I get the following

{"features": [], "fields": []}  

Am I missing something? Seems all to easy up until this point.

Tags (1)
0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

Your code as posted doesn't work:

>>> import arcgis.gis
>>> 
>>> gis = GIS()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'GIS' is not defined
>>> 
 ‍‍‍‍‍‍‍

I know how to fix that error, but then I simply run into the next NameError with FeatureLayer.  Please post functioning code that generates the empty results you are speaking of.

0 Kudos