Giter VIP home page Giter VIP logo

represent-maps's Introduction

Represent API: Maps

This app generates colorful map layers for Google Maps API or OpenLayers, and is based on the represent-boundaries app by OpenNorth, a fork of a similar project by the Chicago Tribune named django-boundaryservice.

The boundaries_us repository provides a full deployment and example data for the United States.

When you use this app, you first load in geographic boundary data from shapefiles using the represent-boundaries management command loadshapefiles. That creates a BoundarySet (which has a slug like congressional-districts) and in that set a Boundary record for each district (a polygon or set of polygons).

Then you create MapLayer records. A MapLayer is a particular set of styling options for a BoundarySet. In a MapLayer, you assign a color to each Boundary. That information is stored in a MapLayerBoundary record (which has a foreign key to the Boundary it corresponds to).

The output are map tile image that would typically be used to overlay on street maps.

The map tiles are not cached within the app. That's your responsibility.

Installation

Besides the dependencies for represent-boundaries, you'll need pycairo2. It's available in Ubuntu 12.04. Your mileage may vary in other cases:

apt-get install python-cairo # (there's no PIP for Python 2?)

Or you can use cairocffi as a replace for pycairo, that installs with pip in a virtualenv, runs on Python 2 and 3, as well as PyPy.

pip install cairocffi

Add maps to INSTALLED_APPS in your settings.py.

Run python manage.py syncdb to create the new tables.

Place in your urls.py:

(r'', include('maps.urls')),

Creating map layers

First load in the boundaries data:

python manage.py loadshapefiles --only [your-boundary-set-slug]

Then create a new map layer with automatically chosen colors for each boundary:

python manage.py create-layer -c [your-boundary-set-slug]

A new layer is created with the same slug as the BoundarySet. The -c option assigns colors to each Boundary.

Then launch the server and view a map example at:

/map/demo/[your-boundary-set-slug]/

For an example with real data, see boundaries_us.

represent-maps's People

Contributors

chrux avatar joshdata avatar michaelmulley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

michaelmulley

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.