Spatial data frame failing to output as feature class

525
1
03-03-2022 09:03 AM
MicahJohns
New Contributor

My ultimate goal is this:

  1. Start with a CSV
  2. Turn that CSV into a spatial data frame 
  3. Turn that spatial data frame into a feature layer - This is where I'm failing
  4. Append the data from that feature layer to another existing hosted feature layer

Step 1 works fine.

df = pd.read_csv("/arcgis/home/Chicago Homicide csv.csv")

#specifically changes a column to date and time
df['Date'] = pd.to_datetime(df['Date'])
#df.dtypes
df.head()

Step 2 also works fine

#makes a sdf and specifies the xy coord columns
sdf = GeoAccessor.from_xy(df,'Longitude','Latitude')
#df.dtypes

sdf.head()
sdf.spatial.plot()

This is the third and failing step

sdf.spatial.to_featureLayer('sdf_to_featureLayer')

#this is the resulting error
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_393/3728460398.py in <module>
----> 1 sdf.spatial.to_featureLayer('spf_to_featureLayer')

AttributeError: 'GeoAccessor' object has no attribute 'to_featureLayer'

 

I've been up and down forums in search of a solution, I actually used the answers from this post (ESRI community link) to get to where I am.

Any thoughts are much appreciated!

1 Reply
RaviNarayanan
Esri Contributor

Hi @MicahJohns I don't see the import statements in your example above, so not sure how it was defined. can you try adding:

from arcgis.features import GeoAccessor