Combining additional data with Shapefile using GeoJSON and Gdal

孤街浪徒 提交于 2019-12-11 07:45:42

问题


I used Mike Bostock's great tutorial to make a simple map using downloaded shapefiles and processing them with GDAL into GeoJSON files.

http://bost.ocks.org/mike/map/

I'm trying to build on this learning by taking a county-level shapefile map and marrying it with additional demographic data (CSV) so that I can load a single GeoJSON file and not have to use Javascript to merge the data at runtime. The goal is to have a county-level heatmap.

The CSV file has an ID column that looks like this: 01348. While the Shapefile has two ID columns that are 01 and 348.

Is it possible to use GeoJSON to store this kind of data? If so, what kind of terminal commands must I use to combine the two?


回答1:


Little trick:

  1. When converting from Shape file to GeoJSON, keep "id-a":"01";"id-b":"348" as neighbors in this order.
  2. use a simple regex to delete all ";"id-b":" and thus obtain "id-a":"01348".
  3. go ahead to inject your CSV property given the common ID, see: How to add properties to topojson file?

That's should work.



来源:https://stackoverflow.com/questions/18560541/combining-additional-data-with-shapefile-using-geojson-and-gdal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!