地图从http://thematicmapping.org/downloads/world_borders.php下载,使用vpn下载。
确保安装好python和gdal
import os
os.chdir("Pah/to/thefile/world.shp")
import osgeo.ogr
shapefile = ogr.Open("world.shp")
layer = shapefile.GetLayer(0)
for i in range(layer.GetFeatureCount())
feature = layer.GetFeature(i)
countryName = feature.GetField("NAME")
countryCode = feature.GetField("ISO3")
geometry = feature.GetGeometryRef()
minlong,maxlong,minLat,maxLat = geometry.GetEnvelope()
print countryName,countryCode,minlong,maxlong,minLat,maxLat
本文介绍如何使用Python和GDAL库处理从特定网站下载的世界地图数据。通过读取.shp文件,获取每个国家的名称、ISO代码及其地理边界信息。
1万+

被折叠的 条评论
为什么被折叠?



