How to convert ESRI or MapInfo GIS data to images using free tools?

The Australian Electoral Commission has free ESRIs and MapInfo forms the GIS layers of the Australian election borders for download . I want to convert this data into a sketch polygon image using a free tool.

+4
source share
3 answers

I assume that you need a separate image for each electorate? If so, I would use the following approach using python:

Read the geometry with GDAL / OGR:

Install the GDAL / OGR tools and their python bindings . Download the ESRI shapefile for election boundaries. Make sure you can read the polygon geometry using 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() 

Derive geometry using matplotlib through beautiful, descartes

Install matplotlib , shapely and descartes . Modify the above script to load each polygon into matplob through beautiful and descartes:

 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() 

Obviously, you need to fix this a bit to make it draw as you want, but the general approach should be sound.

+4
source

Download and use QGIS - www.qgis.org This handy open source tool works well and opens up many typical formats (i.e. form files originally developed by ESRI). It also has an integrated OGR tool.

Plus it's just fun to play and easy to use.

+2
source

Check FWTools .

There is also a helpful mailing list if you need help with conversions.

+1
source

Source: https://habr.com/ru/post/1315363/


All Articles