简体   繁体   English

基于Lon / Lat坐标数组创建多边形进行映射-Python PANDA

[英]Create Polygons for Mapping based on array of Lon/Lat Coordinates--Python PANDAs

I have a PANDAs dataframe with an array of Lon/Lat coordinates, in each row, corresponding to a distinct AREA, per each row. 我有一个PANDAs数据帧,每行中都有一个Lon / Lat坐标数组,每行对应一个不同的AREA。 I'd like to create a mapped group of polygons with boundaries from each row's Array of Coordinates. 我想创建一个多边形映射的组,其边界来自每一行的坐标数组。

The rows of the 'coords' column look like this and each boundary coordinate is separated by Commas... 'coords'列的行看起来像这样,每个边界坐标由逗号分隔...

    coords
0   -88.12166374975578 42.13019789209025, -88.12166297898594 42.130077282796826, -88.12166229779616 42.12997073740438, -88.12165682902426 42.129114208546525, -88.12165440666122 42.12867029753218, -88.12165409167278 42.12861210461891, -88.12165078955562 42.1280072560737, -88.1216505237599 42.127958648542936, -88.12164976861018 42.127820070569165, -88.12164950156834 42.127770730347784, -88.12164936198349 42.127745113495685, -88.12164631909246 42.12698047923614, -88.12164465148149 42.126561239318384, -88.12164441208937 42.126501380826646, -88.12165535387125 42.125918676152615, -88.12165901489989 42.1257236125411, -88.12166910482216 42.125179681003004, -88.12167046792653 42.12511347549821, -88.12168153859359 42.124574951678966, -88.12169213266428 42.12405994975595, -88.12169609920953 42.123867...
1   -88.15806483536268 42.15423929791892, -88.15734814434225 42.15424023425998, -88.15692561771552 42.15424078182948, -88.15612280604331 42.15424182229812, -88.15570230201315 42.154247060953836, -88.15537304882349 42.15424548051985, -88.15424894139665 42.15424008174756, -88.15312432528388 42.15423466567452, -88.15200516375596 42.15422926640768, -88.15075402101326 42.1542232181898, -88.15074137162432 42.15422315689777, -88.15073738857417 42.15384470168878, -88.1507388608806 42.15329655518857, -88.15074017125366 42.15246856985761, -88.15074053615406 42.15224538180373, -88.15074152744889 42.151633597914206, -88.15074252669456 42.15055197422978, -88.15074334980639 42.15033614385567, -88.15074448165737 42.15003982848825, -88.15074567060333 42.14972749019171, -88.15074611950101 42.14952766024307...

Use geopandas 使用geopandas

import geopandas as gpd, pandas as pd
from shapely.geometry import Point, MultiPoint

def s2g(s):
    return gpd.GeoSeries([
        Point(xy) for xy in [
            tuple(float(x) for x in t.split()) for t in s.split(',')
        ]
    ], crs=dict(init='epsg:4326'))

gs = gpd.GeoSeries(pd.concat({r: s2g(v) for r, v in df.coords.items()}))

gs.plot()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Python中计算lat / lon多边形的面积 - Calculating area from lat/lon polygons in Python 基于 lon、lat 和 0 和 1 的数组使用 rasterio 和 shapely 创建多边形 - Creating polygons using rasterio and shapely based on a lon, lat and an array of 0's and 1's 如何在python中为数据集分配纬度/经度坐标? - How to assign lat/lon coordinates to a dataset in python? 将dfs与最近的Lon,Lat(Python,Pandas)进行比较 - compare dfs with nearest Lon,Lat (Python, Pandas) 使用Python中的经/纬坐标创建六边形单元的2D网格 - Create a 2D grid of hexagonal cells using lat/lon coordinates in Python 将经纬度坐标添加到单独的列(python/dataframe) - Adding Lat Lon coordinates to separate columns (python/dataframe) 如何转换pandas中的lat / lon点并查看它们是否属于某些边界多边形? - How to convert lat/lon points in pandas and see whether they fall in some boundary polygons? 如何在 Pandas 中将坐标从 NAD83 转换为常规 gps 坐标(纬度/经度)? - How to convert coordinates from NAD83 to regular gps coordinates (lat/lon) in pandas? 根据纬度/经度计算密度 - Calculate Density based on Lat/Lon 如何识别xarray中的时间,长度和纬度坐标? - How to identify time, lon, and lat coordinates in xarray?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM