Geojson to shapefile using Python

后端 未结 1 500
没有蜡笔的小新
没有蜡笔的小新 2021-02-06 11:36

I\'m trying to convert a geojson file into a shapefile. I\'m trying this way (I\'m very new to Python so it might be incorrect).

import urllib, geojson, gdal
url         


        
1条回答
  •  离开以前
    2021-02-06 12:06

    ogr2ogr appears to be a command line program - to use this you might want to look into something like subprocess.Popen():

    import urllib, geojson, gdal, subprocess
    url= ' http://ig3is.grid.unep.ch/istsos/wa/istsos/services/ghg/procedures/operations/geojson?epsg=4326'
    response = urllib.urlopen(url)
    data = geojson.loads(response.read())
    
    with open('data.geojson', 'w') as f:
        geojson.dump(data, f)
    
    args = ['ogr2ogr', '-f', 'ESRI Shapefile', 'destination_data.shp', 'data.geojson']
    subprocess.Popen(args)
    

    EDIT: In response to comments - yes, pickle is not the appropriate way to go about writing to the file in this case.

    0 讨论(0)
提交回复
热议问题