从多边形的形状文件反转地理编码。
intersectshape的Python项目详细描述
从多边形的形状文件反转地理编码
怎么做?
ReverseGeolocShapefile类将shapefile.Reader类改进为 添加intersection方法以查找与单个多边形相交的多边形 要点。
我使用一个简单的空间索引来存储每个多边形的边界框。 我将这些信息保存在.dbf/^{tt6}旁边的.sidx.npy文件中$ 文件
与Python3.6+一起使用(我正在使用f-string)。
文件
ReverseGeolocShapefile类的intersection方法返回一个列表 行索引的。
用法
import intersectshape shp = intersectshape.ReverseGeolocShapefile('/path/of/shapefile.shp') # You can use all methods of shapefile.Reader object like... row = shp.record(5) geo = shp.shape(2) # Find polygons that intersects a point x, y = 200, 500 # must be at the same projection system ids = shp.intersection(x, y) print(ids) # return [] or [0, 5, 9, 7] for example.