Como faço para converter dados ESRI ou MapInfo GIS em imagens usando ferramentas gratuitas?[fechado]

StackOverflow https://stackoverflow.com/questions/3226018

Pergunta

A Comissão Eleitoral Australiana possui camadas GIS em formato ESRI e MapInfo gratuitas das fronteiras eleitorais australianas para download.Quero converter esses dados em uma imagem poligonal em miniatura usando uma ferramenta gratuita.

Foi útil?

Solução

Presumo que você queira uma imagem separada para cada eleitorado.Nesse caso, eu adotaria a seguinte abordagem usando python:

Leia a geometria usando GDAL/OGR:

Instale o Ferramentas GDAL/OGR e seus ligações python.Baixe o shapefile ESRI para os limites eleitorais.Certifique-se de poder ler a geometria do polígono usando 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()

Produza a geometria usando matplotlib via shapely, descartes

Instalar matplotlib, bem torneado e descartes.Modifique o script acima para carregar cada polígono no matplob via shapely e 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()

Obviamente, você precisa consertar um pouco isso para desenhar como deseja, mas a abordagem geral deve ser sólida.

Outras dicas

Baixe e use QGIS - www.qgis.org Esta ferramenta acessível de código aberto funciona bem, e abre muitos formatos típicos nativamente (isto é, arquivos de forma, originalmente desenvolvidos por ESRI) Também possui uma ferramenta integrada do OGR.

mais é apenas divertido brincar e fácil de usar.

Check-out fwtools .

Há também um lista de discussão útil Se você precisar de ajuda nas conversões.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top