Bolton-and-Menk-GIS / restapi

Python API designed to work externally with ArcGIS REST Services to query and extract data, and view service properties. Uses arcpy for some functions if available, otherwise uses open source alternatives to interact with the ArcGIS REST API. Also includes a subpackage for administering ArcGIS Server Sites.
GNU General Public License v2.0
93 stars 31 forks source link

Feature layer clip fails when no features intersected #37

Closed TylerJ-BMI closed 3 years ago

TylerJ-BMI commented 3 years ago

Getting a TypeError within iter_queries . The OBJECT_IDS key is in the resp but the value is Null so it's failing during sorted

  File "L:\Users\tylerjo\Documents\gitProjects\BMI_Library\tools\clip_swppp_utils.py", line 84, in _clip_rest
    fl.clip(clip_poly, tmp_fc, where=where)
  File "\\arcserver1\GIS\_Resources\ESRI\Python\Staging\VirtualEnvs\py_379_x64\Lib\site-packages\restapi\common_types.py", line 2151, in clip
    return self.export_layer(output, fields, where, exceed_limit=True, **params)
  File "\\arcserver1\GIS\_Resources\ESRI\Python\Staging\VirtualEnvs\py_379_x64\Lib\site-packages\restapi\common_types.py", line 2078, in export_layer
    for fs in self.query_in_chunks(where, fields, f=DEFAULT_REQUEST_FORMAT, **kwargs):
  File "\\arcserver1\GIS\_Resources\ESRI\Python\Staging\VirtualEnvs\py_379_x64\Lib\site-packages\restapi\common_types.py", line 1760, in query_in_chunks
    for where2 in self.iter_queries(max_recs=records, **params):
  File "\\arcserver1\GIS\_Resources\ESRI\Python\Staging\VirtualEnvs\py_379_x64\Lib\site-packages\restapi\common_types.py", line 1652, in iter_queries
    oids = sorted(resp.get(OBJECT_IDS, []))[:max_recs]
TypeError: 'NoneType' object is not iterable

Maybe just call sorted on oids if not null?

resp:

{
  "geometryType": "esriGeometryPoint",
  "objectIdFieldName": "FID",
  "objectIds": null,
  "spatialReference": {
    "latestWkid": 3857,
    "wkid": 102100
  }
}