Code Monkey home page Code Monkey logo

utfgrid-example-writers's Introduction

UTFGrid Example Writers

Sample implementations for writing UTFGrids.

For details on the UTFGrid spec see:

https://github.com/mapbox/utfgrid-spec

Background

These examples are designed to be simple and with few dependencies.

They demonstrate how to author UTFGrids, but not how to serve them. For server implementations see:

https://github.com/mapbox/utfgrid-spec/wiki/Implementations

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

  1. 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
  1. 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
  1. 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.

utfgrid-example-writers's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.