Skip to content
Advertisement

Export properties into .geojson file using geopandas

I have a script that creates a lot of Polygons using Shapely and then exports them as .geojson files. See toy example below

JavaScript

However, I also have a list of numbers, each number is associated with one ploygon. Is there a way to export this with the GeoJSON file inside properties?

For example, if I have a list:

JavaScript

In the .geojson file I would like the properties section for the first polygon to read

“properties”:{“detection_prob”:0.8}

and for the second polygon

“properties”:{“detection_prob”:0.9}

etc etc etc… in the outputted GeoJSON file.

Advertisement

Answer

If you call to_file on a dataframe instead of a series, you can add extra attributes as columns:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement