spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'

06-16-2021 09:14 AM
Regular Contributor

The Spatial DataFrame is unable to export to a Hosted Feature Layer at API version 1.8.5. It seems the to_featurelayer function should handle batching. The feature layer I am exporting from has 219k records. 


from arcgis.gis import GIS
import pandas as pd
gis = GIS(url, username, password)

premiseLayer = gis.content.get(fsItemId)
fLyr = premiseLayer.layers[0]
df = pd.DataFrame.spatial.from_layer(fLyr)



File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\, in to_featurelayer:
Line 2182:  return content.import_data(self._data, folder=folder, title=title, tags=tags)

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\, in import_data:
Line 5361:  res =, postdata)#, use_ordered_dict=True) - OrderedDict >36< PropertyMap

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\, in post:
Line 720:   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\, in _handle_response:
Line 502:   raise Exception(data['error'])

Exception: {'code': 400, 'message': 'The maximum number of records allowed (1000) has been exceeded.', 'requestId': '', 'traceId': 'f7ed4d8d8f6b6647b195319ca2c420a8'}


Tags (1)
0 Kudos
4 Replies
Occasional Contributor III

@PhilLarkin1 did you ever get this to work? i am having the same issue

0 Kudos
Regular Contributor

The details are a little foggy, but I was able to use this. The trick might have been generating the dataframe from the GeoAssessor class vs creating a dataframe from the pandas library. Here is what I have now:

from arcgis.features import FeatureLayer
from arcgis.features import GeoAccessor

serviceUrl = "https://services<x><orgId>/arcgis/rest/services/<ServiceName>/FeatureServer/0"
FL = FeatureLayer(serviceUrl)
DF = GeoAccessor.from_layer(FL)
globalIDLookupTempSDEF = DF.spatial.to_featurelayer(title='GlobalIDLookupTemp',tags='<tag>',folder='<folder>')


Regular Contributor

By the way, what is fantastic about the dataframe created from GeoAssessor is that the GlobalID of the source feature layer is retained.

0 Kudos
Occasional Contributor III

thanks @PhilLarkin1 i'll give it a go

0 Kudos