arcgis-python-api icon indicating copy to clipboard operation
arcgis-python-api copied to clipboard

GeoAccessor from csv or excel fails to read geometry_column

Open hildermesmedeiros opened this issue 2 years ago • 2 comments

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. image

This can be easily fixed in your api image

hildermesmedeiros avatar Jul 20 '22 15:07 hildermesmedeiros

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)

achapkowski avatar Jul 20 '22 15:07 achapkowski

Maybe those steps could be implemented some where? I suppose in the part of the code that uses the parameter geometry_columns

hildermesmedeiros avatar Jul 20 '22 16:07 hildermesmedeiros

Closing this issue how to successfully work this data is provided.

jyaistMap avatar Oct 25 '22 15:10 jyaistMap