Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I merge multiple topojson files into single topojson file

Tags:

topojson

I have US state topojson and Canada state topojson I want to merge them into single file. Can some one tell me how to merge two files into single topojson file. I'm using mercator projection while creating map

like image 1000
dinesh Avatar asked Oct 28 '15 11:10

dinesh


People also ask

What is TopoJSON file?

A TopoJSON file format is a geoJSON format extension that encodes geospatial topology. TopoJSON files contain both attribute data and geospatial data (arcs).


Video Answer


1 Answers

I was facing a similar issue, and ended up converting topojson files to geojson, merging them with geojson-merge, finally converting to topojson.

As Canada and the US share some boundaries (arcs in topojson), it should reduce the total file size.

for item in "us" "ca"
do
    topo2geo tracts=$item-geo.json < $item-topo.json
done
geojson-merge *-geo.json > combined-geo.json
geo2topo tracts=combined-geo.json > combined-topo.json
like image 167
Nobu Avatar answered Oct 05 '22 15:10

Nobu