Hi,
I'm trying to export a SpatialDataFrame which I've imported from ArcGis Online as such:
gis = GIS("site_url", "username", password)
feature_layers=gis.content.get("some_id")
all_layers=feature_layers.layers #get all layers
SDF= SpatialDataFrame.from_layer(all_layers[0])
I need to use the SpatialDataFrame to do some spatial queries to modify the data, (text fields)
When I try to export to a ShapeFile I get this error:
SDF.to_featureclass("output_folder","output_file.shp")
>>The following rows could not be written to the table: 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28
If I try :
SDF.to_featureclass("output_folder","output_file.shp", skip_invalid=False)
Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\_data\geodataset\io\fileops.py", line 579, in to_featureclass
icur.insertRow(row)
RuntimeError: Cannot find field 'b'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#26>", line 1, in <module>
SDF.to_featureclass("output_folder","output_file.shp",skip_invalid=False)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\_data\geodataset\geodataframe.py", line 1399, in to_featureclass
overwrite=overwrite, skip_invalid=skip_invalid)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\_data\geodataset\io\fileops.py", line 583, in to_featureclass
raise Exception("Invalid row detected at index: %s" % index)
Exception: Invalid row detected at index: 0
If i open the file created ( no records) the second column is missing ? and an Id column has been inserted
any ideas ? I've made sure no fields are blank,null or None , I've tried renaming the columns
Update: I Read in a Shapefile and tried to write it back to a new shapefile in a different folder with a different name and it gives the same error
Solved! Go to Solution.
Even if this is a bug, Esri is not going to patch 1.4.1. I recommend upgrading to the latest version of the API (Install and set up | ArcGIS for Developers ) to see if the latest version is impacted. Also, I would try using the new Spatially-Enabled DataFrame. If the issue persists after those changes, then it will be worth raising to Esri Support.
What version of ArcGIS API for Python are you using? Also, are you using the Spatial DataFrame, deprecated since version 1.5, or the Spatially-Enabled DataFrame (Introduction to the Spatially Enabled DataFrame | ArcGIS for Developers)?
I'm using the python environment from ArcGis pro, but where the arcgis package version is 1.4.1 and it says my python packages are up to date.
Even if this is a bug, Esri is not going to patch 1.4.1. I recommend upgrading to the latest version of the API (Install and set up | ArcGIS for Developers ) to see if the latest version is impacted. Also, I would try using the new Spatially-Enabled DataFrame. If the issue persists after those changes, then it will be worth raising to Esri Support.
Thanks, that has fixed my issue, I was trying initially to use Spatially-Enabled DataFrame as I've only recently installed arcgis pro I assumed the latest version of arcgis would be installed.
If your issue has been resolved, either mark someone's response as the correct answer or the question as assumed answered to close it out.