Skip to content

Instantly share code, notes, and snippets.

@lmullen
Created October 8, 2014 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmullen/511643b0564f3aa5444a to your computer and use it in GitHub Desktop.
Save lmullen/511643b0564f3aa5444a to your computer and use it in GitHub Desktop.
Mapping slavery starter kit
# A Makefile to re-project and simplify shapefiles.
SIMPLIFY_PERCENTAGE := 2.5
REPROJECTION_CODE := EPSG:4326
SIMPLIFIED := $(patsubst shp/%.shp, shp_out/%.shp, $(wildcard shp/*.shp))
REPROJECTED := $(patsubst shp/%.shp, temp/%.shp, $(wildcard shp/*.shp))
all : $(SIMPLIFIED)
.SECONDARY : $(REPROJECTED)
shp_out/%.shp : temp/%.shp
@echo "Simplifying $*"
mkdir -p shp_out
mapshaper $^ auto-snap -simplify $(SIMPLIFY_PERCENTAGE)% -o force $@
temp/%.shp : shp/%.shp
@echo "Reprojecting $*"
mkdir -p temp
ogr2ogr -t_srs $(REPROJECTION_CODE) $@ $^
clean :
rm -f temp/*
clobber : clean
rm -f shp_out/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment