<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded' in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166697#M7326</link>
    <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayer
from arcgis.features import GeoAccessor

serviceUrl = "https://services&amp;lt;x&amp;gt;.arcgis.com/&amp;lt;orgId&amp;gt;/arcgis/rest/services/&amp;lt;ServiceName&amp;gt;/FeatureServer/0"
FL = FeatureLayer(serviceUrl)
DF = GeoAccessor.from_layer(FL)
globalIDLookupTempSDEF = DF.spatial.to_featurelayer(title='GlobalIDLookupTemp',tags='&amp;lt;tag&amp;gt;',folder='&amp;lt;folder&amp;gt;')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Apr 2022 16:33:33 GMT</pubDate>
    <dc:creator>PhilLarkin1</dc:creator>
    <dc:date>2022-04-21T16:33:33Z</dc:date>
    <item>
      <title>spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1068957#M6211</link>
      <description>&lt;P&gt;The Spatial DataFrame is unable to export to a Hosted Feature Layer at API version 1.8.5. It seems the &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.html?highlight=dataframe#arcgis.features.SpatialDataFrame.to_featurelayer" target="_self"&gt;to_featurelayer&lt;/A&gt; function should handle batching. The feature layer I am exporting from has 219k records.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)

df[columnList].spatial.to_featurelayer('NewName',folder='folderName')

...

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_accessor.py, 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\__init__.py, in import_data:
Line 5361:  res = self._portal.con.post(path, postdata)#, use_ordered_dict=True) - OrderedDict &amp;gt;36&amp;lt; PropertyMap

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\_impl\_con\_connection.py, 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\_connection.py, 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'}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 16:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1068957#M6211</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2021-06-16T16:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166547#M7325</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242657"&gt;@PhilLarkin1&lt;/a&gt;&amp;nbsp;did you ever get this to work? i am having the same issue&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 09:44:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166547#M7325</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2022-04-21T09:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166697#M7326</link>
      <description>&lt;P&gt;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:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayer
from arcgis.features import GeoAccessor

serviceUrl = "https://services&amp;lt;x&amp;gt;.arcgis.com/&amp;lt;orgId&amp;gt;/arcgis/rest/services/&amp;lt;ServiceName&amp;gt;/FeatureServer/0"
FL = FeatureLayer(serviceUrl)
DF = GeoAccessor.from_layer(FL)
globalIDLookupTempSDEF = DF.spatial.to_featurelayer(title='GlobalIDLookupTemp',tags='&amp;lt;tag&amp;gt;',folder='&amp;lt;folder&amp;gt;')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 16:33:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166697#M7326</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-04-21T16:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166699#M7327</link>
      <description>&lt;P&gt;By the way, what is fantastic about the dataframe created from GeoAssessor is that the GlobalID of the source feature layer is retained.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Apr 2022 16:34:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1166699#M7327</guid>
      <dc:creator>PhilLarkin1</dc:creator>
      <dc:date>2022-04-21T16:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: spatial.to_featurelayer fails with 'maximum number of records allowed has been exceeded'</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1167406#M7336</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/242657"&gt;@PhilLarkin1&lt;/a&gt;&amp;nbsp;i'll give it a go&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2022 09:19:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/spatial-to-featurelayer-fails-with-maximum-number/m-p/1167406#M7336</guid>
      <dc:creator>StuartMoore</dc:creator>
      <dc:date>2022-04-25T09:19:16Z</dc:date>
    </item>
  </channel>
</rss>

