我怎样转换ESRI或MapInfo地理信息系统数据图像使用免费工具?[关闭]
-
14-09-2020 - |
题
澳大利亚选举委员会具有免费和ESRI MapInfo甲酸GIS层的澳大利亚选举的边界 下载.我想要转换这些数据,以缩略多边形图像的使用免费工具。
解决方案
我假设你想要一个单独的图像对每个选民?如果是这样,我将采取以下方法使用蟒蛇:
阅读几何使用GDAL/OGR:
安装的 GDAL/OGR工具 和他们的 蟒蛇绑定的.下载ESRI形状的选举界限。确保你可以读取多边形几何使用OGR:
import sys
import ogr
ds = ogr.Open( "/path/to/boundary/file.shp" )
if ds is None:
print "Open failed.\n"
sys.exit( 1 )
lyr = ds.GetLayer(0)
lyr.ResetReading()
feat = lyr.GetNextFeature()
while feat is not None:
geom = feat.GetGeometryRef()
if geom is None or geom.GetGeometryType() != ogr.wkbPolygon:
print "no poly geometry\n"
feat = lyr.GetNextFeature()
ds.Destroy()
输出的几何使用matplotlib通过匀称的,笛卡尔
安装 matplotlib, 身材匀称 和 笛卡尔.修改上述脚本以负载各多边形成matplob通过匀称和笛卡尔:
import sys
import ogr
from shapely.wkb import loads
from descartes import PolygonPatch
from matplotlib import pyplot
ds = ogr.Open( "/path/to/boundary/file.shp" )
if ds is None:
print "Open failed.\n"
sys.exit( 1 )
lyr = ds.GetLayer(0)
lyr.ResetReading()
feat = lyr.GetNextFeature()
while feat is not None:
geom = feat.GetGeometryRef()
if geom is None or geom.GetGeometryType() != ogr.wkbPolygon:
print "no poly geometry\n"
else:
# create matplotlib figure:
fig = pyplot.figure(1, figsize = [10,10], dpi = 300) #create 10x10 figure
ax = fig.addsubplot(111) #Add the map frame (single plot)
# add polygon:
patch = PolygonPatch(loads(feature.GetGeometryRef().ExportToWkb()), plus colour and line considerations)
ax.addpatch(patch) # simply add the patch to the subplot
# set plot vars
ax.set_xlim(get xmin and xmax values from data)
ax.set_ylim(get ymin and ymax values from data)
ax.set_aspect(1)
# save as image
pyplot.savefig('somefile.png', some arguments you like)¶
feat = lyr.GetNextFeature()
ds.Destroy()
很明显你需要修复这一点得到它提请你怎么想的,但一般的做法应该是声音。
不隶属于 StackOverflow