小编ark*_*tke的帖子

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

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

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

谢谢.

最终解决方案

#!/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)
Run Code Online (Sandbox Code Playgroud)

python gis shapefile

5
推荐指数
1
解决办法
2391
查看次数

获取 Matplotlib 图例位置?

我想获取 matplotlib 图例的位置(轴数据或比例的 x,y)。我已经尝试过以下方法:

l = ax.legend(...)
l.get_window_extent()
l.legendPatch.get_bbox().inverse_transformed(ax.transAxes) 
Run Code Online (Sandbox Code Playgroud)

我的目标是使用图例的位置添加一个文本框,旁边包含附加信息。

python matplotlib

5
推荐指数
1
解决办法
8882
查看次数

如何绘制复杂的多边形?

我正在从GIS数据库中读取数据并使用mpl_toolkits.basemap和matplotlib创建地图.一些数据创建复杂的多边形(由外部和内部环定义).但是,我无法追踪如何创建带孔的多边形.matplotlib甚至可以实现这一点吗?还有另一种创建此图像的方法吗?

python matplotlib

1
推荐指数
2
解决办法
3191
查看次数

标签 统计

python ×3

matplotlib ×2

gis ×1

shapefile ×1