You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the only production-ready write implementation for UTFGrids is found inside Mapnik's
grid_renderer which
which uses AGG rendering to quickly render a feature hit grid in a single pass over geometries.
Mapnik's python
or node.js
bindings can then be used to encode to UTFGrid format as JSON objects.
Because this Mapnik implementation is complex, and written in C++, simpler examples are needed
that prioritize simplicity and ease of understanding over rendering speed.
Reference Implementations
ogr_renderer.py
This uses the OGR library and its python bindings to query
a polygon shapefile, build a pixel buffer of feature ids, and then encode those
ids in UTFGrid format.
View a sample grid in your terminal by doing:
python ogr_renderer.py
And pretty print the json like:
python ogr_renderer.py | python -mjson.tool
mapnik_renderer.py
This sample matches the ogr example, but uses Mapnik's AGG-based scanline rendering of grid ids, which is sensitive to the exact styles applied to geometries - allowing it to work equally well for encoding interactive pixels of both points, lines, polygons, text, and svg/png symbols (their shape).
This example requires Mapnik >= 2.0.0.
View the sample output like:
python mapnik_renderer.py | python -mjson.tool
fiona_rtree_renderer.py
This one uses an in memory rtree index to speed up the loop creating the grid, and a fiona collection to read the shapefile.
About
Simple reference implementations for creating UTGGrid tiles