so i want to query a feature layer thats accessed via AGOL but the actual features are served up from ArcGIS Server (i think its 10.3)
i have this in an ArcGIS Pro Notebook and it should be returning the second set of 100 records but instead its returning all 1800 records
UpdsFeat = FeatLyr.query(where = "DATEMODIFIED > (CURRENT_TIMESTAMP-45)",result_offset = 100, result_Record_Count = 100)
is is because the feature service is coming from an old version of ArcGIS Server that doesn't support the result_record_count & Results_offset?
thanks
Stu
Solved! Go to Solution.
i couldn't get that to work so just used the objectIDs and did a filter to bring them back in small chunks of 1000, it then loads each chunk into a pandas dataframe
steps = 1000
z = 0
sOID = 1
MaxOID = 391283
while sOID < (MaxOID+steps):
whereFil = "objectid >={0} and objectid < {1}".format(sOID,sOID+steps)
Upd2k = xxdata.query(where = whereFil,out_fields = outFields)
sOID +=steps
if z == 0:
resdf = pd.DataFrame(Upd2k.sdf)
z +=1
else:
resdf = resdf.append(pd.DataFrame(Upd2k.sdf), ignore_index=True)
It's possible that the age of the server has something to do with it. Can you open the service JSON and see if those capabilities are there?
thanks @jcarlson yea they are not available in the json so i guess its the server, i guess there is no way around it
In addition to those parameters, try setting the return_all_records parameter to False.
thanks @MobiusSnake i tried that but it just came up with this error:
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
In [97]:
Line 2: UpdsFeat = FeatLyr.query(where = "DATEMODIFIED > (CURRENT_TIMESTAMP-45)", return_all_records = False, result_offset = 100, result_Record_Count = 100)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py, in query:
Line 1727: return self._query(url, params, raw=as_raw)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py, in _query:
Line 2998: return self._query(url, params, raw=False, add_token=False)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py, in _query:
Line 3034: raise queryException
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\layer.py, in _query:
Line 2984: path=url, postdata=params, add_token=kwargs.get("add_token", True)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in post:
Line 1079: force_bytes=kwargs.pop("force_bytes", False),
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_response:
Line 625: self._handle_json_error(data["error"], errorcode)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_json_error:
Line 648: raise Exception(errormessage)
Exception: Unable to complete operation.
Unable to perform query operation.
(Error Code: 400)
i couldn't get that to work so just used the objectIDs and did a filter to bring them back in small chunks of 1000, it then loads each chunk into a pandas dataframe
steps = 1000
z = 0
sOID = 1
MaxOID = 391283
while sOID < (MaxOID+steps):
whereFil = "objectid >={0} and objectid < {1}".format(sOID,sOID+steps)
Upd2k = xxdata.query(where = whereFil,out_fields = outFields)
sOID +=steps
if z == 0:
resdf = pd.DataFrame(Upd2k.sdf)
z +=1
else:
resdf = resdf.append(pd.DataFrame(Upd2k.sdf), ignore_index=True)