小编Gus*_*Gus的帖子

使用Python将Geojson转换为shapefile

我正在尝试将geojson文件转换为shapefile。我正在尝试这种方式(我是Python的新手,所以可能不正确)。

import urllib, geojson, gdal
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())

file = open ('data.geojson', 'w')
pickle.dump(data,file)
file.close()
ogr2ogr -f "ESRI Shapefile" destination_data.shp "data.geojson"
Run Code Online (Sandbox Code Playgroud)

因此,我从URL获取数据,将其放入文件中,当我尝试将其转换为shapefile时,出现此错误:

 File "<stdin>", line 1
    ogr2ogr -f "ESRI Shapefile" destination_data.shp "data.geojson"
                              ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

因为我还很新,所以尝试了在网上找到的解决方案。有什么办法可以使这项工作吗?

干杯,

G

python shapefile geojson

4
推荐指数
1
解决办法
5444
查看次数

标签 统计

geojson ×1

python ×1

shapefile ×1