I have a python dictionary looking like this:
{0: [[806735.1544109267, 6537534.445304121],
[841214.0757437024, 6522224.452253355],
[842501.6252045294, 6522869.442922172],
[842549.1443712532, 6522901.510964515],
[806735.1544109267, 6537534.445304121]],
1: [[841408.2671391629, 6521335.689519852],
[841100.3038260225, 6520996.388704606],
[842331.2640584556, 6520540.411264208],
[841950.1552972465, 6521128.964539945],
[841408.2671391629, 6521335.689519852]],
2: [...]}
It corresponds to multipolygons. Each polygon is defined by a number (0, 1, etc.) and a list of coordinates in 2154 (scr). My goal is to turn this dictionary into another format that I can easily manipulate ( geodataframe ), so that I could read it in GIS (as a shapefile for instance). Has anyone an idea?
If you want an id column and a geometry column, 'id'
and 'geometry'
should be the keys in your dictionary:
import geopandas as gdp
d = {
'id': [0, 1],
'geometry': [
[
[806735.1544109267, 6537534.445304121],
[841214.0757437024, 6522224.452253355],
[842501.6252045294, 6522869.442922172],
[842549.1443712532, 6522901.510964515],
[806735.1544109267, 6537534.445304121]
],
[
[841408.2671391629, 6521335.689519852],
[841100.3038260225, 6520996.388704606],
[842331.2640584556, 6520540.411264208],
[841950.1552972465, 6521128.964539945],
[841408.2671391629, 6521335.689519852]
],
]
}
gdf = gdp.GeoDataFrame(d)
More information and examples in geopandas documentation
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.