python - 如何使用 python 查找 ESRI shapefile 中特定纬度/经度的信息?

标签 python gis shapefile

我有一个 ESRI shapefile(来自这里:http://pubs.usgs.gov/ds/425/)。我希望使用 python 在给定的纬度/经度下从形状文件(在本例中为表面 Material )中查找信息。

解决这个问题的最佳方法是什么?

谢谢。

最终解决方案:

#!/usr/bin/python

from osgeo import ogr, osr

dataset = ogr.Open('./USGS_DS_425_SHAPES/Surficial_materials.shp')
layer = dataset.GetLayerByIndex(0)
layer.ResetReading()

# Location for New Orleans: 29.98 N, -90.25 E
point = ogr.CreateGeometryFromWkt("POINT(-90.25 29.98)")

# Transform the point into the specified coordinate system from WGS84
spatialRef = osr.SpatialReference()
spatialRef.ImportFromEPSG(4326)
coordTransform = osr.CoordinateTransformation(
        spatialRef, layer.GetSpatialRef())

point.Transform(coordTransform)

for feature in layer:
    if feature.GetGeometryRef().Contains(point):
        break

for i in range(feature.GetFieldCount()):
    print feature.GetField(i)

最佳答案

检查 Python Shapefile Library

这应该给你几何和不同的信息。

关于python - 如何使用 python 查找 ESRI shapefile 中特定纬度/经度的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4596843/

相关文章:

python - 修改多边形,使它们不重叠并且面积保持不变

python - 在 geopandas 中转换为字符串时几何列被修剪

swing - 如何在 Java Swing 应用程序中嵌入 Maven 项目

python - 字典中的交叉列表(超过两个)

python - 使用 http.client.https.connnection 向 microsoft azure 服务发出连接请求以分析图像

python - 使用 Matplotlib 绘制等高线图和线框图

python - 对值进行排序并查找最佳分数(最高数字)

gis - Cesium - 将广告牌/ map 图钉放置在具有 extrudedHeight 设置的多边形上

r - 从铁路网络 shapefile 中提取车站之间的路线

r - ggplot2 的功能强化错误