I am currently pulling data from an api that is in a json format.
I convert this into a geodataframe using the lat lon columns provided in the dataset.
df_points = gpd.GeoDataFrame.from_dict(all_results)
df_points['lon'] = df_points['lon'].astype(float)
df_points['lat'] = df_points['lat'].astype(float)
df_points['geometry'] = [shapely.geometry.Point(xy) for xy in zip(df_points.lon, df_points.lat)]
gdf = df_points
sedf = arcgis.GeoAccessor.from_geodataframe(gdf)
This part works fine even if it may not be elegant.
From here I can save it off as a shapefile no problem
I would like to send it directly to my GeoDatabase as a Feature Class
however when I attempt to I get an error.
sedf.spatial.to_featureclass(r'...\MyProject.gbd\sample')
--------------------------
AttributeError Traceback(most recent call last)
In[23]:
Line 1: sedf.spatial.to_featureclass(r'...\MyProject.gbd\sample')
File ...\site-packages\arcgis\feature\geo\_accesspr.py, in to_featureclass:
Line 2668: result = to_featureclass(
File ...\site-packages\arcgis\features\geo\_io\fileops.py, in to_featureclass"
Line 1262: raise e
File ...\site-packages\arcgis\features\geo\_io\fileops.py, in to_featureclass:
Line 1075: "point": pd.io.json.dumps(
AttributeError: module 'pandas.io.json' has no attribute 'dumps'
-----------------------
Any thoughts why I am seeing this.
I do thought it might be conflicting with the json library but I removed it and it is still popping this error.
Solved! Go to Solution.
Unfortunately cannot remove posts so replying again with the solution
As of Panda's 2.2.x
pandas calls json.dumps as json.udumps
In order to get .to_featureclass, arcgis is now reliant on pandas version 2.1.x or older
!pip install pandas == 2.1
df_points = gpd.GeoDataFrame.from_dict(all_results)
df_points['lon'] = df_points['lon'].astype(float)
df_points['lat'] = df_points['lat'].astype(float)
df_points['geometry'] = [shapely.geometry.Point(xy) for xy in zip(df_points.lon, df_points.lat)]
gdf = df_points
sedf = arcgis.GeoAccessor.from_geodataframe(gdf)
sedf.spatial.to_featureclass(r'...\MyProject.gbd\sample')
Hey @RobertKleisley
Do you happen to have anything named json.py or json.x (x being any extension)? I've had this exact issue before due to it picking up something named json.
I'd attempt to move this to a different location and give it another shot to see!
Hope that helps!
Cody
I'm unsure what you mean.
something named json saved anywhere in the GDB?
anything named json in my Python3 directory where my packages are installed?
Digging into this a bit.
I have figured out that I am using pandas 2.2.x
as of this version pandas imports json.udumps not json.dumps
Unfortunately cannot remove posts so replying again with the solution
As of Panda's 2.2.x
pandas calls json.dumps as json.udumps
In order to get .to_featureclass, arcgis is now reliant on pandas version 2.1.x or older
!pip install pandas == 2.1
df_points = gpd.GeoDataFrame.from_dict(all_results)
df_points['lon'] = df_points['lon'].astype(float)
df_points['lat'] = df_points['lat'].astype(float)
df_points['geometry'] = [shapely.geometry.Point(xy) for xy in zip(df_points.lon, df_points.lat)]
gdf = df_points
sedf = arcgis.GeoAccessor.from_geodataframe(gdf)
sedf.spatial.to_featureclass(r'...\MyProject.gbd\sample')