将 Geojson 信息转换为 geopandas 几何

Converting Geojson information to geopandas geometry

我有这样的 geojson 文件:

   location = {'type': 'Polygon',
   'coordinates': [[[[-90.06, 29.34],
    [-89.8, 29.15],
    [-89.55, 29.26],
    [-89.61, 29.27],
    [-89.6, 29.35],
    [-89.67, 29.31],
    [-89.77, 29.33],
    [-89.75, 29.41],
    [-89.81, 29.43],
    [-89.83, 29.49],
    [-89.93, 29.51],
    [-89.94, 29.48],
    [-90.07, 29.55],
    [-90.17, 29.51],
    [-90.06, 29.43],
    [-90.06, 29.34]]]]}

我想提取多边形信息并在 geopandas 数据框中保存为多边形几何图形。我无法转换从 geojson 中提取此信息 如果有人能提供帮助,我将不胜感激

  • 您可以从 dict snippet
  • 构建有效的 geojson
  • 你的坐标太深因此取第一维的第零个元素
location = {
    "type": "Polygon",
    "coordinates": [
        [
            [
                [-90.06, 29.34],
                [-89.8, 29.15],
                [-89.55, 29.26],
                [-89.61, 29.27],
                [-89.6, 29.35],
                [-89.67, 29.31],
                [-89.77, 29.33],
                [-89.75, 29.41],
                [-89.81, 29.43],
                [-89.83, 29.49],
                [-89.93, 29.51],
                [-89.94, 29.48],
                [-90.07, 29.55],
                [-90.17, 29.51],
                [-90.06, 29.43],
                [-90.06, 29.34],
            ]
        ]
    ],
}

gpd.GeoDataFrame.from_features(
    [
        {
            "type": "Feature",
            "properties": {},
            "geometry": {
                **location,
                **{"coordinates": location["coordinates"][0]},
            },
        }
    ]
)
geometry
0 POLYGON ((-90.06 29.34, -89.8 29.15, -89.55 29.26, -89.61 29.27, -89.59999999999999 29.35, -89.67 29.31, -89.77 29.33, -89.75 29.41, -89.81 29.43, -89.83 29.49, -89.93000000000001 29.51, -89.94 29.48, -90.06999999999999 29.55, -90.17 29.51, -90.06 29.43, -90.06 29.34))