澳大利亚选举委员会有免费的ESRI和MapInfo合作澳大利亚选举界线的GIS图层download。我想使用免费工具将这些数据转换为缩略图多边形图像。如何使用免费工具将ESRI或MapInfo GIS数据转换为图像?
4
A
回答
4
我假设你想为每个选民单独的图像?如果是的话,我会使用python采取如下方法:
阅读使用GDAL/OGR几何:
安装GDAL/OGR tools及其python bindings。下载选举界限的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几何,笛卡尔
安装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()
显然,你需要解决这个问题了一点得到它吸引你怎么想,但一般的做法应该是声。
1
结账FWTools。
如果您需要转换帮助,还有一个helpful mailing list。
2
下载和使用QGIS - www.qgis.org 这个方便的开源工具运行良好,并在本地打开了许多典型格式(即最初由ESRI开发的形状文件)。它也有一个内置的OGR工具。
加上它只是玩的乐趣,并易于使用。
相关问题
- 1. GIS数据转换
- 2. 如何将数据转换为图像?
- 3. 免费的DTD到XSD转换工具?
- 4. 免费的XSD到DTD转换工具?
- 5. 有没有任何免费的工具将html页面转换为图片?
- 6. 使用mathjax或类似工具将Latex/MathML转换为SVG或图像?
- 7. 如何从任何免费工具或简单的转换器学习HTML
- 8. 你知道任何免费的GIS卫星图像吗?
- 9. 如何使用Javascript将网页转换为PDF或图像?
- 10. 一个免费的GIS库支持光栅图像建议
- 11. 他们的任何免费的PHP图书馆将PPT或ODT转换为PDF
- 12. 如何将bytearray转换为图像或图像bytearray?
- 13. 将BLOB数据转换为图像
- 14. 免费或开源的.Net数据库视图/编辑工具,如phpMyAdmin
- 15. 开源或免费线框工具
- 16. C#html to pdf converter使用wkhtmltopdf或任何其他免费工具
- 17. 将图像转换为iPhone工具栏图标
- 18. 如何将位图转换为图像
- 19. 如何将图像转换为图标?
- 20. 免费角色扮演如何将%SUBST转换为TIMESTAMP?
- 21. 如何使用swift将图像数组转换为anyobject
- 22. 将二进制数据转换为图像-Silverlight或Asp.Net
- 23. 如何将VRLM文件转换为3D PDF? (python或免费软件)
- 24. 使用OpenCV将云数据转换为2d图像
- 25. 以MapInfo格式转换地图
- 26. 如何将base64编码数据转换为xcode图像
- 27. 如何将二进制数据转换为图像?
- 28. 如何将blob数据转换为JavaScript中的图像?
- 29. 如何将原始数据转换为android中的图像?
- 30. 如何将RGBA数据转换为base64显示图像