Skip to content

Commit

Permalink
[#1] Worldpop raster import
Browse files Browse the repository at this point in the history
  • Loading branch information
iperdomo committed Dec 20, 2017
1 parent 86b1264 commit 248f465
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# mapnik-raster-colorizer

Example of Mapnik raster colorizer

## Usage

docker-compose up --build -d

## Raster dataset license

[WorldPop](http://www.worldpop.org.uk/data/summary/?doi=10.5258/SOTON/WP00234) datasets
are licensed under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/)

> Africa population count data: Linard, C., Gilbert, M., Snow, R.W., Noor, A.M. and Tatem, A.J., 2012,
> Population distribution, settlement patterns and accessibility across Africa in 2010, PLoS ONE, 7(2): e31743.

## License

LGPL v2.1 [Same as Mapnik](https://github.com/mapnik/mapnik#license)
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "3"
services:
postgres:
build:
context: ./postgres
environment:
- POSTGRES_PASSWORD=sa
volumes:
- ./rasters:/rasters
ports:
- "5432:5432"
9 changes: 9 additions & 0 deletions postgres/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM mdillon/postgis:9.6

RUN set -ex; apt-get update && \
apt-get install -y gdal-bin && \
rm -rf /var/lib/apt/lists/* && \
mkdir /rasters && \
chown postgres:postgres -R /rasters;

COPY raster-import.sh /docker-entrypoint-initdb.d/
27 changes: 27 additions & 0 deletions postgres/raster-import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash

set -eu

GEOTIFF="SLE10adjv4.tif"
ARCHIVE="/rasters/SLE.tar.gz"
DB_NAME="sierra_leone"

if [[ ! -f "${ARCHIVE}" ]]; then
exit 1;
fi

echo "CREATE DATABASE ${DB_NAME} TEMPLATE template_postgis" | psql -U postgres -h localhost

cd /tmp

tar xvfz "${ARCHIVE}"

# Import - No transformation

raster2pgsql -C -I -Y "${GEOTIFF}" -t 128x128 sle_pop | psql -U postgres -h localhost -d "${DB_NAME}"

# Reproject and compress

gdalwarp -ot Byte -co COMPRESS=LZW -t_srs EPSG:3857 "${GEOTIFF}" "sle-wm.tif"

raster2pgsql -C -I -Y "sle-wm.tif" -t 128x128 sle_pop_wm | psql -U postgres -h localhost -d "${DB_NAME}"
Binary file added rasters/SLE.tar.gz
Binary file not shown.
Binary file added rasters/worldpop-SLE.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 248f465

Please sign in to comment.