Datasette for geospatial analysis
The SpatiaLite extension for SQLite can be used with Datasette to enable a full suite of geospatial SQL functions.
Datasette has a number of plugins and tools that can be used to work with geospatial data.
Geospatial plugins include:
- datasette-cluster-map renders a map of markers for any table or query with
latitude
andlongitude
columns - datasette-geojson adds a
.geojson
extension which can export SpatiaLite geometries as GeoJSON - datasette-geojson-map renders that GeoJSON output on a map
- datasette-leaflet-freedraw adds an interface to filter geometries by drawing a shape on a map
- datasette-leaflet-geojson shows maps inline for any column that includes GeoJSON
- datasette-tiles allows Datasette to serve map tile images stored using the MBTiles format
Tools for working with geospatial data include:
- geojson-to-sqlite, a command line utility for loading GeoJSON data into a SQLite or SpatiaLite database
- shapefile-to-sqlite, a command line utility for loading shapefiles into SQLite or SpatiaLite
- download-tiles can be used to download map tiles and store them in MBTiles, suitable for use with datasette-tiles
The following tutorials provide more detail on how Datasette can be used for geospatial processing:
- GUnion to combine geometries in SpatiaLite shows how to load Amtrak data using
geojson-to-sqlite
and render it usingdatasette-geojson-map
- KNN queries with SpatiaLite shows how to use the KNN feature to run queries showing the nearest geometries to a point
- Natural Earth in SpatiaLite and Datasette shows how to use the 791MB Natural Earth SQLite vector database with Datasette
- Drawing shapes on a map to query a SpatiaLite database introduces the
datasette-leaflet-freedraw
plugin