IndexError trying to write spatial dataframe to feature

1102
5
Jump to solution
10-09-2019 09:52 AM
CarlSunderman
Occasional Contributor

so there is something wrong with this dataframe, that it seems i cant see. 

SOURCEChangeSHAPE
1file_c-0.29
{'rings': [[[1788402.41, 13301439.29...
2file_c-0.24
{'rings': [[[1788428.41, 13301463.29...
5file_c-0.24
{'rings': [[[1788447.41, 13301429.29...

When i try to write this to a featureclass 

df.spatial.to_featureclass(r"C:\tmp\sample.shp")

I get

IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`)....

What am i missing with this dataframe? 

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

I am not sure if this is your only issue, but the syntax of you method call is incorrect:

to_featureclass(out_location, out_name, overwrite=True, skip_invalid=True)

converts a SpatialDataFrame to a feature class

ArgumentDescription
out_locationRequired string. A save location workspace
out_nameRequired string. The name of the feature class to save as
overwriteOptional boolean. True means to erase and replace value, false means to append
skip_invalidsOptional boolean. If True, any bad rows will be ignored.
Returns:string

View solution in original post

5 Replies
JoshuaBixby
MVP Esteemed Contributor

I am not sure if this is your only issue, but the syntax of you method call is incorrect:

to_featureclass(out_location, out_name, overwrite=True, skip_invalid=True)

converts a SpatialDataFrame to a feature class

ArgumentDescription
out_locationRequired string. A save location workspace
out_nameRequired string. The name of the feature class to save as
overwriteOptional boolean. True means to erase and replace value, false means to append
skip_invalidsOptional boolean. If True, any bad rows will be ignored.
Returns:string
CarlSunderman
Occasional Contributor

No, it works as i posted on all other dataframes. 

perhaps those docs are out of date?

arcgis.features module — arcgis 1.6.2 documentation 

to_featureclass(location, overwrite=True)
exports a geo enabled dataframe to a feature class.

So like i said, there is something odd with this dataframe that i can't seem to find

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

My bad, i thought you were using the older spatial dataframe, not the current geo-enabled dataframe.  The syntax changed with the new dataframe. 

What are the dtypes of the dataframe?

0 Kudos
CarlSunderman
Occasional Contributor

No problem, but as shocking as this may sound, i do believe that it was user error after all.  

it was just where i was appending the dataframes earlier in the code. I still marked your response as helpful and correct. 

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Ah, it happens to the best of us.  Since my response didn't directly address your issue, I will unmark my answer as correct, but I will mark the thread as assumed answered to close it out.

UPDATE:  I forgot I am not a moderator in this space, so I can't make the change I stated above.  I can't wait to get off this old Jive product for GeoNet.

0 Kudos