Created by Joachim Ungar / @ungarjo
EOX IT Services / eox.at
This work is licensed under a Creative Commons Attribution 4.0 International License.
gdaldem hillshade srtm.vrt hillshade.tif
gdal_contour srtm.vrt contours.shp
source: wikipedia
tiled data → CartoCSS/mapfile → map tile
tiled data → process → process output tile
mapchete_serve
mapchete_execute
--overwrite
mapchete_serve
mapchete_execute
--zoom 0 8
--tile 5 6 7
--bounds 10 40 12 50
your_process.mapchete
%YAML 1.2
---
process_file: # path to process (python file)
input_files:
file1: # path to file 1
file2: # path to file 2
output:
path: # absolute output path
format: # PNG, PNG_hillshade, GTiff, GeoJSON, PostGIS or NumPy
type: # geodetic or mercator
dtype: # bool, uint8, uint16, int16, uint32, int32, float32, float64
bands: # number of output bands
nodata: # nodata value
your_process.mapchete
process_minzoom: # minimum zoom level this process is valid
process_maxzoom: # maximum zoom level this process is valid
process_bounds: # left bottom right top in "type" CRS
metatiling: # (default is 1); has to be one of 2, 4, 6, 8 or 16
light_azimuth: 315 # user defined parameters
exaggeration: # user defined parameters dependending on zoom level
zoom<5: 10
zoom>=5: 5
your_process.py
#!/usr/bin/env python
from mapchete import MapcheteProcess
class Process(MapcheteProcess):
"""Main process class"""
def __init__(self, **kwargs):
"""Process initialization"""
MapcheteProcess.__init__(
self,
identifier = "my_process_id",
title="My long process title",
version = "0.1",
abstract="short description on what my process does",
)
def execute(self):
"""User defined process"""
# insert magic here
your_process.py
with self.open(
self.params["input_files"]["raster_file"], # object containing process config
resampling="bilinear" # rasterio resampling
) as my_raster_rgb_file:
if my_raster_rgb_file.is_empty(): # if empty, quit tile process
return "empty"
r, g, b = my_raster_rgb_file.read() # read RGB bands
your_process.py
self.write((r, g, b)) # tuple of bands
self.write(hillshade_array) # single band as array
self.write(features) # GeoJSON-like vector data
GeoTIFF, PNG, PNG_hillshade, GeoJSON, NumPy, PostGIS
hillshade()
contours()
clip()
PyPi: https://pypi.python.org/pypi/mapchete
GitHub: https://github.com/ungarj/mapchete
twitter: @mapchete
Joachim Ungar @ungarjo
EOX IT Services eox.at