-1

enter image description here

I am trying to convert the data shown here into a .csv that contains these following fields

enter image description here

The current script I have takes in the .shp using geopandas and outputs it as a csv. However, the normal geopandas to csv conversion only gets the shapefile data and the shape geometries. How can I also get the geography object as well included in this or at least the geographical coordinates?

1
  • Add the code you are using to convert it to csv Commented Feb 5 at 17:38

1 Answer 1

0

If you want to add a column that has the coordinates of the polygons, you could do something like this :

usa_gdf["geography"] = usa_gdf["geometry"].apply(lambda geom: {"coordinates": [list(coord) for coord in geom.exterior.coords]})

The apply function is meant to perform a specific operation on the dataframe for each row. Here we are using the geometry column, and for each geometry, we extract it's outer ring's coordinates and put that into a new column and we format it however we want. Make sure your data has the WGS84 CRS and if not, create a copy and use this projection.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.