How to convert country level geojson using QGIS using data from naturalearthdata .org

StackOverflow https://stackoverflow.com/questions/21512445

  •  06-10-2022
  •  | 
  •  

Question

I have to create 170 topojson for 170 countries from a single geojson file. I am using shape file from naturalearthdata.org admin 1 state county level map. I use QGIS desktop software to create geojson file .

1.How to create geojson file for 170 country using QGIS individually(170 geojson file) I am able to convert earthdata admin 1 level data to single geojson which covers all countries in the world.

2.Is there any other easy tool where i can create geojson file from shapefile, as for 170 countries it involves a lot of manual work to convert. Can you point me to some sites where this step is already done and i can start using it.

Was it helpful?

Solution

  1. In Qgis divide your shapefile into countries by country ID with: Vector > Data Management > Split Vector layer

  2. Change into the directory with the 170 shapefiles and use topojson commandline to directly convert to topojson:

Linux/Mac

for f in *.shp; do topojson -o  `basename $f .shp`.json $f; done

Win

for %f in (*shp) do topojson -o %~nf.json %f

PS. You might consider posting GIS related questions on https://gis.stackexchange.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top