arcgis-python-api
arcgis-python-api copied to clipboard
GeoAccessor from csv or excel fails to read geometry_column
We can save Geodf to csv or excel but the import fails
If we can save ours df to csv, to excel, we should be able to import it properly.
This can be easily fixed in your api
It seems the to_excel
on Pandas is not converting the dictionary (Geometries) to a string.
I recommend you convert the Geometry
column to a string
using json.dumps
then saving it out.
sdf_to_excel = sdf.copy()
sdf_to_excel.SHAPE= sdf_to_excel.SHAPE.apply(json.dumps)
sdf_to_excel.to_excel(r"c:/temp/mydata.xlsx")
When pulling the data back in, do the following:
sdf_from_excel = pd.read_excel(mypath)
sdf_from_excel.SHAPE = sdf_from_excel.SHAPE.apply(json.loads)
sdf_from_excel.spatial.set_geometry("SHAPE")
print(sdf_from_excel.spatial.bbox)
Maybe those steps could be implemented some where? I suppose in the part of the code that uses the parameter geometry_columns
Closing this issue how to successfully work this data is provided.