如何/在哪里获得非美国国家,省份和行政区域的geoJSON数据? [英] How/Where do I get geoJSON data for states, provinces, and administrative regions of non-US countries?

查看:813
本文介绍了如何/在哪里获得非美国国家,省份和行政区域的geoJSON数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要针对多个国家/地区内的州,省和地区的geoJSON格式化路径。最容易获得的geoJSON数据是针对美国各州和国家层面的边界,而不是国内的区域。这个geoJSON将用于使用D3.js创建地理可视化。

解决方案

有一个很好的写法如何生成geoJSON from shapefileshereÚ
http://vallandingham.me/shapefile_to_geojson.html



以下步骤需要您从头到尾完成:


  1. 安装Quantum GIS框架 http://www.qgis.org/e/qgis

    如果您使用的是Mac OS X,则可以使用此版本 http://www.kyngchaos。 com / software

    这将为您提供用于将shapefiles转换为geoJSON的ogr2ogr实用程序


  2. 下载shapefile您的国家/地区 http://www.gadm.org/country 并解压缩


  3. 对于加拿大和其他国家,带后缀0的shapefile是国家
    边界,后缀1是内部区域。


  4. 将区域级别shapefile上传到MapShaper http://mapshaper.com/test/MapShaper.swf

    如果您不在乎,可以跳过此步骤


  5. 将MapShaper中的简化级别滑块设置为所需级别,并将简化的shapefile导出为Shapefile - Polygons


  6. 将.shp和.shx文件下载到您解压缩原始
    shapefiiles的本地目录,将原始文件替换为简单版本。 / p>


  7. 导航到本地目录并运行以下命令,将< shapefile> 替换为您想要的shape文件的实际名称convert。



    ogr2ogr -f geoJSON regions.json< shapefile> .shp


您现在应该具有geoJSON格式的您所在国家的地区。检查以确保在regions.json中定义了路径,并且维护了属性字段(例如区域名称)。


I need geoJSON formatted paths for states, provinces, and regions within multiple countries. Most readily available geoJSON data is for US states and country level boundaries, not regions within the country. This geoJSON will be used to create a geographic visualization using D3.js.

解决方案

There is a good writeup on how to generate geoJSON from shapefiles here
http://vallandingham.me/shapefile_to_geojson.html

The steps below should take you from start to finish:

  1. Install the Quantum GIS framework http://www.qgis.org/e/qgis.
    If you are on Mac OS X, you can use this version http://www.kyngchaos.com/software
    This will give you the ogr2ogr utility used for converting shapefiles to geoJSON

  2. Download the shapefiles for your country from here http://www.gadm.org/country and unzip

  3. For Canada, and possibly other countries, the shapefile with suffix 0 is for the country boundary and the suffix 1 is for the internal regions. Not sure if this naming is consistent across countries.

  4. Upload the region level shapefile to MapShaper http://mapshaper.com/test/MapShaper.swf
    You can skip this step if you don't care to optimize the size of your resulting geoJSON

  5. Set the 'simplification level' slider in MapShaper to the desired level and export the simplified shapefile as 'Shapefile - Polygons'

  6. Download .shp and .shx file to the local directory where you unzipped the original shapefiiles, replace the original files with the simplified ones.

  7. Navigate to the local directory and run the command below, replacing <shapefile> with the actual name of the shapefile you want to convert.

    ogr2ogr -f geoJSON regions.json <shapefile>.shp

You should now have the regions for your country in geoJSON format. Check to make sure there are paths defined in regions.json and that property fields were maintained (ex. region name).

这篇关于如何/在哪里获得非美国国家,省份和行政区域的geoJSON数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆