Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/russss/datasette-geo
A Datasette plugin to make Spatialite databases effortlessly explorable
https://github.com/russss/datasette-geo
datasette geojson geospatial mapbox-gl-js maps python sqlite
Last synced: 3 months ago
JSON representation
A Datasette plugin to make Spatialite databases effortlessly explorable
- Host: GitHub
- URL: https://github.com/russss/datasette-geo
- Owner: russss
- License: apache-2.0
- Created: 2019-04-29T20:35:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-01T09:48:21.000Z (over 5 years ago)
- Last Synced: 2024-10-10T22:38:04.000Z (3 months ago)
- Topics: datasette, geojson, geospatial, mapbox-gl-js, maps, python, sqlite
- Language: Python
- Homepage:
- Size: 526 KB
- Stars: 10
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/simonw/datasette) plugin to make [Spatialite](https://www.gaia-gis.it/fossil/libspatialite/index) databases effortlessly explorable.
## Features
* [All the good stuff from Datasette](https://datasette.readthedocs.io/en/stable/)
* 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](doc/screenshot.png)
## 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:
```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](https://datasette.readthedocs.io/en/stable/spatialite.html).
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](https://openstreetmap.org) 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](https://operations.osmfoundation.org/policies/tiles/).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](https://account.mapbox.com/access-tokens/).
You'll also need a style URL, which can either be one of Mapbox's [default styles](https://docs.mapbox.com/api/maps/#mapbox-styles)
or a custom style generated with [Mapbox Studio](https://studio.mapbox.com/).Configure it in your `metadata.json`:
```json
"plugins": {
"datasette-geo": {
"mapbox_token": "",
"style": "mapbox://styles/mapbox/light-v10"
}
}
```
### MapTiler
[MapTiler](https://maptiler.com) 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](https://cloud.maptiler.com/maps/) and you'll be given a vector style URL:
```json
"plugins": {
"datasette-geo": {
"style": "https://api.maptiler.com/maps/positron/style.json?key="
}
}
```### Custom Style File
You can generate a custom [Mapbox GL style file](https://docs.mapbox.com/mapbox-gl-js/style-spec/) using a tool like
[Maputnik](https://maputnik.github.io/), 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:
```json
"plugins": {
"datasette-geo": {
"style": "/static/mystyle.json"
}
}
```