【问题标题】:Converting Geojson information to geopandas geometry将 Geojson 信息转换为 geopandas 几何
【发布时间】:2021-11-11 17:26:35
【问题描述】:

我有这样的 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 中提取此信息时遇到问题 如果有人可以提供帮助,我将不胜感激

【问题讨论】:

    标签: python geojson geopandas


    【解决方案1】:
    • 您可以从 dict sn-p
    • 构造有效的 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))

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-19
      • 1970-01-01
      • 2020-07-22
      • 2023-01-18
      • 2015-07-29
      • 1970-01-01
      相关资源
      最近更新 更多