From b4f4c9aa1b701f7b8dd5b5cd37f6b53e7fe252ea Mon Sep 17 00:00:00 2001 From: Jeremy Stucki Date: Mon, 21 Sep 2015 18:43:19 +0200 Subject: [PATCH] Add custom simplification option --- Makefile | 16 ++++++++++------ README.md | 8 ++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index b66de8b5..2fdba7d6 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,10 @@ ENCODING = utf8 CONTOUR_INTERVAL = 500 +ifndef SIMPLIFY + SIMPLIFY = $(if $(REPROJECT),1e-9,.5) +endif + all: topo topo: node_modules \ @@ -387,7 +391,7 @@ topo/%.json: build/%.json $(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \ --no-pre-quantization \ --post-quantization=1e5 \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ $(if $(PROPERTIES),-p $(PROPERTIES),) \ -- $< @@ -398,7 +402,7 @@ topo/%-municipalities-lakes.json: build/%-municipalities.json build/%-lakes.json $(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \ --no-pre-quantization \ --post-quantization=1e5 \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ $(if $(PROPERTIES),-p $(PROPERTIES),) \ -- $^ @@ -409,7 +413,7 @@ topo/ch-%-lakes.json: build/ch-%.json build/ch-lakes.json $(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \ --no-pre-quantization \ --post-quantization=1e5 \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ $(if $(PROPERTIES),-p $(PROPERTIES),) \ -- $^ @@ -420,7 +424,7 @@ topo/ch.json: $(addprefix build/ch-,$(addsuffix .json,municipalities cantons dis $(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \ --no-pre-quantization \ --post-quantization=1e5 \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ $(if $(PROPERTIES),-p $(PROPERTIES),) \ -- $^ @@ -456,7 +460,7 @@ topo/ch-plz.json: build/ch/plz.shp node_modules/.bin/topojson \ -o $@ \ $(if $(REPROJECT),,--width $(WIDTH) --height $(HEIGHT) --margin $(MARGIN)) \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ --id-property +PLZ \ -- plz=$< @@ -522,7 +526,7 @@ topo/ch-contours.json: build/ch/contours.shp mkdir -p $(dir $@) node_modules/.bin/topojson \ $(if $(REPROJECT),,--width $(WIDTH) --height $(HEIGHT) --margin $(MARGIN)) \ - --simplify $(if $(REPROJECT),1e-9,.5) \ + --simplify=$(SIMPLIFY) \ --id-property=+elev \ -- contours=$< \ | node_modules/.bin/topojson-group \ diff --git a/README.md b/README.md index 323cbe1b..a2dd7b60 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,14 @@ Municipality boundaries from 2013 and 2014 are also available. If you want bound make topo/ch-municipalities.json YEAR=2013 +## Custom Simplification + +To use a custom simplification, define the `SIMPLIFY` variable. For example, to create a really blocky version of Switzerland: + + make topo/ch-country.json SIMPLIFY=400 + +*Note:* The simplify parameter has [different meanings depending on the coordinate system](https://github.com/mbostock/topojson/wiki/Command-Line-Reference#simplification). + ## Other Modifications For everything else you can modify the `Makefile` or run `ogr2ogr` and `topojson` directly. Mike Bostock's tutorial [Let's Make a Map](http://bost.ocks.org/mike/map/), the [TopoJSON wiki](https://github.com/mbostock/topojson/wiki), and [ogr2ogr documentation](http://www.gdal.org/ogr2ogr.html) should cover most of your needs.