Simple Rest API for storing “point” observations

Database stuff

First I’ll describe the database that backs the service.

PostGIS database backend

Here is how to make a simple table in PostgreSQL, that can store geo-tagged “observations”. It uses a hstore type for key-value pairs and a geography point for the GPS dot. It’s very versatile, and could store anything from bird observations to endomondo like GPS tracks.

CREATE TABLE observations(
    utc_timestamp TIMESTAMP, 
    geog GEOGRAPHY(Point, 4326), 
    kvp HSTORE

Read more

Plotting data on maps with matplotlib

I’m learning about matplotlib, and actually just bought the book Matplotlib for Python Developers.

Geographical plots

Browsing stackoverflow, the matplotlib homepage, and other resources, I eventually came by this stackoverflow post, which mentions BaseMap. Since the data that I’m plotting is inherently geographical, it makes sense to show the data on a map.

There are several nice examples on the basemap Github page.


Often I want to create heatmaps of the data, using matplotlib.

On stackoverflow there are several posts on this topic:

There are different colormaps available for matplotlib, if you want to try different colorschemes.

Pyramidal tile cache cheat sheet

This table lists the number of total tiles for increasing zoom-level in a tile cache. The tile cache is assumed to be pyramidal: \left|z_{i}\right| = n \Rightarrow \left|z_{i+1}\right| = n \dot 4.

level 1: 1 tile
level 2: 5 tiles
level 3: 21 tiles
level 4: 85 tiles
level 5: 341 tiles
level 6: 1,365 tiles
level 7: 5,461 tiles
level 8: 21,845 tiles
level 9: 87,381 tiles
level 10: 349,525 tiles
level 11: 1,398,101 tiles
level 12: 5,592,405 tiles
level 13: 22,369,621 tiles
level 14: 89,478,485 tiles
level 15: 357,913,941 tiles
level 16: 1,431,655,765 tiles
level 17: 5,726,623,061 tiles
level 18: 22,906,492,245 tiles
level 19: 91,625,968,981 tiles
level 20: 366,503,875,925 tiles
level 21: 1,466,015,503,701 tiles