查看 FWTools 。
还有一个 有用的邮件列表 如果您需要有关转换的帮助。
我假设你想为每个选民分别形象?如果是这样,我会采用以下方法使用python:
安装 GDAL / OGR工具 和他们的 python绑定 。下载选区边界的ESRI shapefile。确保您可以使用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 , 身材匀称 和 笛卡尔 。修改上面的脚本,通过shapely和descartes将每个多边形加载到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()
显然你需要稍微解决这个问题才能得到你想要的结果,但一般的方法应该是合理的。
下载并使用QGIS - www.qgis.org 这个方便的开源工具运行良好,本机打开许多典型格式(即形状文件,最初由ESRI开发)它还有一个内置的OGR工具。
此外,玩起来很有趣,而且易于使用。