python - 使用 Shapely 从四个经纬度角创建多边形
问题描述
我正在尝试使用来自臭氧监测仪器 (OMI) 的数据文件,并将来自该来源的数据与监测类似数据的地表仪器进行比较。
最终,我想找出是否在特定的多边形内。不过,要做到这一点,我需要创建我想象的多边形。
我有以下变量
latmat
latmat[1] = array([-62.2546, -62.371 , -62.4871, -62.6032], dtype=float32)
latmat[2] = array([-62.7195, -62.8356, -62.9519, -63.0676], dtype=float32)
lonmat
lonmat[1] = array([135.579, 135.606, 135.633, 135.66 ], dtype=float32)
lonmat[2] = array([135.688, 135.717, 135.745, 135.774], dtype=float32)
当然,latmat 和 lonmat 都比两个索引大得多,但我试图保持这些简单。这些值分别代表一个四角卫星像素的纬度和经度点。
最重要的是,我还有表格中的数据
data[1] = 1E+15
data[2] = 3E+15
我如何使用 geopandas 创建一个地理数据框,将 4 个纬度/经度点的每个组合识别为一个多边形?
解决方案
您需要为此使用zip()
:
from shapely.geometry import Polygon
import numpy as np
latmat1 = np.array([-62.2546, -62.371 , -62.4871, -62.6032], dtype=np.float32)
latmat2 = np.array([-62.7195, -62.8356, -62.9519, -63.0676], dtype=np.float32)
lonmat1 = np.array([135.579, 135.606, 135.633, 135.66 ], dtype=np.float32)
lonmat2 = np.array([135.688, 135.717, 135.745, 135.774], dtype=np.float32)
pol1 = Polygon([(i,j) for i,j in zip(lonmat1, latmat1 ) ])
pol2 = Polygon([(i,j) for i,j in zip(lonmat2, latmat2 ) ])
推荐阅读
- css - CSS 滚动边距是做什么的
- javascript - 具有 UA 属性和 GA4 属性的 Google Analytics GTag.js,只有 UA 属性接收添加到购物车事件
- r - 如何从 Google Analytics 跟踪 R 闪亮的仪表板事件
- php - 将 SQL 中表情符号的字符串 unicode 表示转换为 Dart(或 PHP)中的实际表情符号
- apache-flink - 如何使用 Flink 中的内存数据创建可刷新的表以进行连接?
- java - Java - 浏览器自动化?
- sql - 仅获取行,直到达到 qty total
- android - 我的 Android 应用显示 Admob 插页式测试广告,但不是真实广告
- c++ - C++ 中的慢 std::vector vs [] - 为什么?
- python - 有没有办法在循环的每次迭代之后在 for 循环中产生“剩余迭代次数”计数?