将 Geojson 信息转换为 geopandas 几何

香烟

我有这样的 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片段中构建有效的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]},
            },
        }
    ]
)
几何学
0 POLYGON((-90.06 29.34,29.15 -89.8,-89.55 29.26,-89.61 29.27,29.35 -89.59999999999999,-89.67 29.31,-89.77 29.33,-89.75 29.41,-89.81 29.43,-89.83 29.49,29.51 -89.93000000000001,-89.94 29.48 , -90.06999999999999 29.55, -90.17 29.51, -90.06 29.43, -90.06 29.34))

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章