Skip to content

Instantly share code, notes, and snippets.

@ajashton
Created December 7, 2010 16:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajashton/731961 to your computer and use it in GitHub Desktop.
Save ajashton/731961 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e -u
# 1. render each layer of each zoom level
# 2. combine each layer of each zoom level to one image in a specified manner
# 3. cut each layer into
#### CONFIGURATION ####
ZMIN=0
ZMAX=5
MAPFILE="land-glow.mml"
TMPDIR="layers"
FINALDIR="/home/aj/Dropbox/geo-un-world/renders"
#### PROGRAM ####
## RENDER BACKGROUND TILES
for L in `seq $ZMIN $ZMAX`; do
# Determine output dimensions based on zoomlevel
Zd=$((256*(2**$L)))
# Render with Mapnik
nik2img.py --no-open \
-d $Zd $Zd \
-e -20037508 -20037508 20037508 20037508 \
"$MAPFILE" "$TMPDIR/land_glow_z$L.png"
# Generate transparency with ImageMagick
convert \
-size ${Zd}x${Zd} xc:black \
"$TMPDIR/land_glow_z$L.png" -alpha Off \
-compose Copy_Opacity -composite \
-format tiff -depth 8 -monochrome -alpha On \
"$TMPDIR/land_glow_trans_z$L.tif"
# Make geotiff with gdal
gdal_translate \
-a_ullr -20037508 20037508 20037508 -20037508 \
-a_srs "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs" \
-co alpha=yes \
"$TMPDIR/land_glow_trans_z$L.tif" \
"$FINALDIR/land_glow_z$L.tif"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment