• Stars
    star
    107
  • Rank 321,651 (Top 7 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 12 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python tools for working with mbtiles databases

python-mbtiles

Some python tools for working with mbtiles:

MBTiles is a specification for storing tiled map data in SQLite databases for immediate use and for transfer. The files are designed for portability of thousands, hundreds of thousands, or even millions of standard map tile images in a single file.

Similar projects

This is nothing more than an experiment at this point. For more full-featured libraries, you may also want to check out

Project Goals

Python classes

Abstract the details of accessing utfgrid and image data from the sqlite datastore. See mbtiles.py

tileset = MbtileSet(mbtiles='./data/road-trip-wilderness.mbtiles')
zoom, col, row = 6, 9, 40
tile = tileset.get_tile(zoom, col, row)
binary_png = tile.get_png()
text_json = tile.get_json()

Tile web server

Provide a fast, simple, non-blocking web server (using Tornado) to serve image and utfgrid data. You are able to pass a callback parameter on utfgrids for dynamic JSONP allowing easy cross-domain and framework-agnostic loading of utfgrid json tiles. See serve_mbtiles.py

python serve_mbtiles.py # runs on 8988
wget http://localhost:8988/test/6/9/40.png
wget http://localhost:8988/test/6/9/40.json
wget http://localhost:8988/test/6/9/40.json?callback=test
wget http://localhost:8988/test/6/9/23.json?origin=top # invert y-axis for top-origin tile scheme like Google, etc.

Covert mbtiles to png/json files

A script to convert mbtiles files into png/json files on the filesystem. This eliminates the single-file advantages of mbtiles but gains portability in that tiles can be served statically without a web server in front of it. See mbtiles2files.py.

# Bottom-origin tiles (TMS)
python mbtiles2files.py -f data/road-trip-wilderness.mbtiles -o /tmp/output
ls /tmp/output/6/9/40.*

# Invert to top-origin tiles (Google, OSM, etc.)
python mbtiles2files.py -f data/road-trip-wilderness.mbtiles -o /tmp/output --invert
ls /tmp/output/6/9/23.*

Example

Roadmap

  • Make error handling more robust
  • Config file for the server (port, list of mbtiles to serve)
  • Handle jpg (coding was stupidly implemented assuming png)
  • Test cases, docs
  • setup.py file, cheesehop it, etc.

More Repositories

1

simanneal

Python module for Simulated Annealing optimization
Python
628
star
2

python-rasterstats

Summary statistics of geospatial raster datasets based on vector geometries.
Python
522
star
3

pyimpute

Spatial classification and regression using Scikit-learn and Rasterio
Python
120
star
4

jenks

Cython implementation of jenks breaks
Python
105
star
5

leaflet-simple-csv

Put points on a map. CSV-driven, clustered, mobile-ready, filterable.
JavaScript
102
star
6

docker-gdal-base

A base docker image for geospatial applications
Dockerfile
58
star
7

geojson-precision

Adjust precision of GeoJSON coordinates
Python
56
star
8

pairing

Encode pairs of integers as single integer values using the Cantor pairing algorithm
Python
38
star
9

pytsp

Python interface to external TSP solvers
Python
31
star
10

bbox-cheatsheet

Reference for comparing software implementations of geospatial bounding boxes
25
star
11

gdal_utils

Random GDAL and OGR scripts to do useful stuff
Python
24
star
12

lambda-rasterio

Building Rasterio apps on AWS Lambda
Python
23
star
13

optimal_tour

Find the shortest tour visiting all GeoJSON points using concorde and mapbox APIs
Python
21
star
14

pi_sensor_realtime

Raspberry Pi, analog sensors, websockets and streaming real time plots
HTML
18
star
15

mower

mower - For controlling GRASS GIS with Python
Python
17
star
16

websocket-geojson-leaflet

Use WebSockets to stream GeoJSON features to a Leaflet map.
JavaScript
16
star
17

spatial-search-showdown

JavaScript
16
star
18

docker-postgres

PostgreSQL and PostGIS, dockerized
Shell
15
star
19

krige

Kriging for Geospatial Interpolation
Rust
10
star
20

smos

Tools for working with Soil Moisture and Ocean Salinity (SMOS) satellite data
Python
8
star
21

vagrant-webmaps

Deploy the ultimate web mapping server with a single command.
HTML
7
star
22

graph-kickr

Visualize Wahoo Kickr workout data
Python
7
star
23

raspberry_pi

Setting up a headless Raspberry Pi with automated code deployments
Python
6
star
24

batch-copy

Tokio actor to batch binary copies into PostgreSQL
Rust
3
star
25

ncvrt

Use VRTs to deal with some quirks of NetCDF and GDAL interaction
Python
3
star
26

projection-finder

Find EPSG Coordinate Reference Systems that match your bounds and criteria
Python
3
star
27

climate_explorer

CSS
3
star
28

pgconman

Manage PostgreSQL connection environment variables
Python
3
star
29

daylight

Visualize sunrise and sunset times
Clojure
3
star
30

climatedata

local point summaries and visualizations of global climate models
Python
3
star
31

notebooks

Personal dev logs as Jupyter notebooks
Jupyter Notebook
2
star
32

geojson-to-gljs

Generate Mapbox GL JS maps from GeoJSON features at the command line
Python
2
star
33

ctr-mtb

Colorado Trail Race Map, MTB
HTML
2
star
34

ghtix

Tools for working with github issue tracker
Python
2
star
35

ergplayer

Little GUI app to "play" .erg files as you ride.
Python
2
star
36

example-mapserver-rs

A proof-of-concept HTTP server and bindings for UMN Mapserver, implemented in Rust
Rust
2
star
37

rio-combine

Find unique combinations of values for two rasters/arrays
Python
2
star
38

fio-stats

Summary statistics for GeoJSON feature properties
Python
2
star
39

csv2sqlite

Does what it says; converts csvs to sqlite tables
Python
2
star
40

geodesicxy

Extract distances and properties over GeoJSON points
Python
1
star
41

archive

old projects for purely historical purposes
JavaScript
1
star
42

mapbox-directions-ui

A MapboxGLJS and Elm interface to mapbox geocoding, directions and trip optimization APIs
Elm
1
star
43

pylas

Automatically exported from code.google.com/p/pylas
Python
1
star
44

rusty-python

Demo: add a little Rust to your Python projects.
Python
1
star
45

wikipedia-geo

Extract and filter geographic data from wikipedia
Python
1
star
46

openpayments

Geography of Health Care Industry Payments, http://perrygeo.github.io/openpayments
JavaScript
1
star
47

geofu

Geofu
Python
1
star
48

iterpipe

Processing pipelines for Python iterables
Python
1
star
49

dockermon

CLI to simplify local monitoring of a docker container's resource usage
Rust
1
star