Skip to content

Commit b4f4c9a

Browse files
committed
Add custom simplification option
1 parent a5815d0 commit b4f4c9a

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

Makefile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ ENCODING = utf8
2020

2121
CONTOUR_INTERVAL = 500
2222

23+
ifndef SIMPLIFY
24+
SIMPLIFY = $(if $(REPROJECT),1e-9,.5)
25+
endif
26+
2327
all: topo
2428

2529
topo: node_modules \
@@ -387,7 +391,7 @@ topo/%.json: build/%.json
387391
$(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \
388392
--no-pre-quantization \
389393
--post-quantization=1e5 \
390-
--simplify $(if $(REPROJECT),1e-9,.5) \
394+
--simplify=$(SIMPLIFY) \
391395
$(if $(PROPERTIES),-p $(PROPERTIES),) \
392396
-- $<
393397

@@ -398,7 +402,7 @@ topo/%-municipalities-lakes.json: build/%-municipalities.json build/%-lakes.json
398402
$(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \
399403
--no-pre-quantization \
400404
--post-quantization=1e5 \
401-
--simplify $(if $(REPROJECT),1e-9,.5) \
405+
--simplify=$(SIMPLIFY) \
402406
$(if $(PROPERTIES),-p $(PROPERTIES),) \
403407
-- $^
404408

@@ -409,7 +413,7 @@ topo/ch-%-lakes.json: build/ch-%.json build/ch-lakes.json
409413
$(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \
410414
--no-pre-quantization \
411415
--post-quantization=1e5 \
412-
--simplify $(if $(REPROJECT),1e-9,.5) \
416+
--simplify=$(SIMPLIFY) \
413417
$(if $(PROPERTIES),-p $(PROPERTIES),) \
414418
-- $^
415419

@@ -420,7 +424,7 @@ topo/ch.json: $(addprefix build/ch-,$(addsuffix .json,municipalities cantons dis
420424
$(if $(REPROJECT),,--width=$(WIDTH) --height=$(HEIGHT) --margin=$(MARGIN)) \
421425
--no-pre-quantization \
422426
--post-quantization=1e5 \
423-
--simplify $(if $(REPROJECT),1e-9,.5) \
427+
--simplify=$(SIMPLIFY) \
424428
$(if $(PROPERTIES),-p $(PROPERTIES),) \
425429
-- $^
426430

@@ -456,7 +460,7 @@ topo/ch-plz.json: build/ch/plz.shp
456460
node_modules/.bin/topojson \
457461
-o $@ \
458462
$(if $(REPROJECT),,--width $(WIDTH) --height $(HEIGHT) --margin $(MARGIN)) \
459-
--simplify $(if $(REPROJECT),1e-9,.5) \
463+
--simplify=$(SIMPLIFY) \
460464
--id-property +PLZ \
461465
-- plz=$<
462466

@@ -522,7 +526,7 @@ topo/ch-contours.json: build/ch/contours.shp
522526
mkdir -p $(dir $@)
523527
node_modules/.bin/topojson \
524528
$(if $(REPROJECT),,--width $(WIDTH) --height $(HEIGHT) --margin $(MARGIN)) \
525-
--simplify $(if $(REPROJECT),1e-9,.5) \
529+
--simplify=$(SIMPLIFY) \
526530
--id-property=+elev \
527531
-- contours=$< \
528532
| node_modules/.bin/topojson-group \

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ Municipality boundaries from 2013 and 2014 are also available. If you want bound
113113

114114
make topo/ch-municipalities.json YEAR=2013
115115

116+
## Custom Simplification
117+
118+
To use a custom simplification, define the `SIMPLIFY` variable. For example, to create a really blocky version of Switzerland:
119+
120+
make topo/ch-country.json SIMPLIFY=400
121+
122+
*Note:* The simplify parameter has [different meanings depending on the coordinate system](https://github.com/mbostock/topojson/wiki/Command-Line-Reference#simplification).
123+
116124
## Other Modifications
117125

118126
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.

0 commit comments

Comments
 (0)