Skip to content

Commit

Permalink
Add custom simplification option
Browse files Browse the repository at this point in the history
  • Loading branch information
jstcki committed Sep 21, 2015
1 parent a5815d0 commit b4f4c9a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ ENCODING = utf8

CONTOUR_INTERVAL = 500

ifndef SIMPLIFY
SIMPLIFY = $(if $(REPROJECT),1e-9,.5)
endif

all: topo

topo: node_modules \
Expand Down Expand Up @@ -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),) \
-- $<

Expand All @@ -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),) \
-- $^

Expand All @@ -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),) \
-- $^

Expand All @@ -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),) \
-- $^

Expand Down Expand Up @@ -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=$<

Expand Down Expand Up @@ -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 \
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b4f4c9a

Please sign in to comment.