I'm trying to simplify several geojson and topojson files at once to output them into one file with a consistent level of detail. I'm using Mapshaper because I like it's map simplification features.

I see in the docs that it has a combine-files feature:

combine-files Import multiple files to separate layers with shared topology. Useful for generating a single TopoJSON file containing multiple geometry objects.

That's exactly what I want to do, but there's no example and everything I've tried doesn't work.

I've tried applying it in the input commands box before upload, at the same time as upload, after upload, with and without quotes, and from the console and output box after upload. They all just show the separate files as separate files.

How do I use combine-files to upload / input multiple files into one?


I noticed that the browser interface seems to automatically treat multiple files as layers, so I tried -merge-layers name="another layer" target="selected layer", or -merge-layers name="another layer", but it replaced the layer instead of merging.

Basically I just want to be able to see and simplify the contents of multiple files at once, to ensure consistency and no gaps between layers that border each other, then output them as (ideally) one file with one layer for each original file.

  • merge-files and combine-files, github.com/mbloch/mapshaper/issues/57 – klewis Aug 8 '16 at 13:59
  • Now I'm even more confused, the docs say combine-files is an input parameter but in that example it's being used for output! Adding it to output gives me an error Unknown output option: combine-files – user568458 Aug 8 '16 at 14:49
up vote 3 down vote accepted

The combine-files option is only for the input (-i) command which is not available on the browser version. When using mapshaper in the browser you can see all your layers but notice that the "source file" for each one is different. I think that the simplification command can only take in consideration layers in the same file, hence the combine-files option exists.

To use the command line version and have a custom input, install Node.js 6.x and then mapshaper by running this command in your terminal (may require sudo):

$ npm install --global mapshaper

Now you can combine the layers in a single file and simplify them with something like this:

$ mapshaper \
    -i ./my-topo-file.json ./my-topo-file2.json ./my-geo-file.json ./my-shape-file.shp snap combine-files \
    -rename-layers topo1,topo2,geo,shape \
    -merge-layers target=topo1,topo2,geo,shape name=merged-layers \
    -simplify weighted 3% \
    -o ./output-topo.json format=topojson target=merged-layers bbox prettify force

To understand the above commands and all others available, see the command line reference.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.