Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
doc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Datasette Geo

Work in progress. Don't expect this to work yet, especially since it depends on a lot of unmerged Datasette features.

A Datasette plugin to make Spatialite databases effortlessly explorable.

Features

  • All the good stuff from Datasette
  • Better representation of Spatialite geometries in table views
  • Fast, scalable map viewing using Mapbox GL and an integrated Mapbox Vector Tile server
  • GeoJSON export endpoints
  • Maybe more?

Datasette Geo Screenshot

Installation

As covered above, please don't try to install this yet. It currently relies on a raft of patches to Datasette, which will hopefully be merged soon.

Database Preparation

The database you're using needs to have the geographic data stored in Spatialite geometry columns. These columns must be indexed, which you can do with the following SQL:

	SELECT CreateSpatialIndex('table_name', 'column_name');

Configuration

You'll need to make sure the Spatialite module is loaded by Datasette, as described in the docs.

After this, Datasette Geo should work out of the box, automatically detecting the Spatialite column in your tables and rendering them. You may want to increase your sql_time_limit_ms configuration setting to allow enough time for large vector tiles to be rendered.

Base Maps

By default, Datasette Geo uses the standard OpenStreetMap raster tiles as a base map, as they require no authentication to access. Please note if you deploy Datasette Geo with these tiles, you must comply with the OSM Tile Usage Policy.

Raster tiles are not as fast and pretty as using a vector tile source, so you can configure Datasette Geo to use a vector tile source instead. Note that (to my knowledge) all available vector tile services are paid services although Mapbox and MapTiler have free tiers:

Mapbox

You'll need a Mapbox account so you can fetch an access token. You'll also need a style URL, which can either be one of Mapbox's default styles or a custom style generated with Mapbox Studio.

Configure it in your metadata.json:

    "plugins": {
	    "datasette-geo": {
		"mapbox_token": "<Mapbox access token>",
		"style": "mapbox://styles/mapbox/light-v10"
	    }
    }

MapTiler

MapTiler is another source of vector tile data which is cheaper than Mapbox. By way of full disclosure, they currently sponsor some of my personal projects with free vector tile access.

Choose your map and you'll be given a vector style URL:

    "plugins": {
	    "datasette-geo": {
		"style": "https://api.maptiler.com/maps/positron/style.json?key=<MapTiler key>"
	    }
    }

Custom Style File

You can generate a custom Mapbox GL style file using a tool like Maputnik, or by hand-writing it if you're especially keen. Note that you will still need to define a tile source in the style file. Add it to your Datasette project static directory, and reference it in metadata.json like so:

    "plugins": {
	    "datasette-geo": {
		"style": "/static/mystyle.json"
	    }
    }

About

A Datasette plugin to make Spatialite databases effortlessly explorable

Topics

Resources

License

Releases

No releases published

Packages

No packages published