Draw polygons on maps in Datasette
Project description
datasette-leaflet-freedraw
Draw polygons on maps in Datasette
Project background: Drawing shapes on a map to query a SpatiaLite database.
Installation
Install this plugin in the same environment as Datasette.
$ datasette install datasette-leaflet-freedraw
Note that this uses a feature that will be released in Datasette 0.54 - so it currently requires the Datasette 0.54a0 alpha.
Usage
This plugin looks for input fields on a page with names ending in _freedraw
- it replaces them with a Leaflet map interface that includes the FreeDraw Leaflet plugin.
Configure canned queries with inputs called freedraw
or ending in _freedraw
to trigger the map interface.
Demo
You can try out this plugin to run searches against the GreenInfo Network California Protected Areas Database. Here's an example query showing mini parks in San Francisco:
select
AsGeoJSON(geometry), *
from
CPAD_2020a_SuperUnits
where
PARK_NAME like '%mini%' and
Intersects(GeomFromGeoJSON(:freedraw), geometry) = 1
and CPAD_2020a_SuperUnits.rowid in (
select
rowid
from
SpatialIndex
where
f_table_name = 'CPAD_2020a_SuperUnits'
and search_frame = GeomFromGeoJSON(:freedraw)
)
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-leaflet-freedraw
python3 -mvenv venv
source venv/bin/activate
Or if you are using pipenv
:
pipenv shell
Now install the dependencies and tests:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for datasette-leaflet-freedraw-0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f9e305fb847f468140714bb0e180f2126a41c3e2628ca098735bef8e8d6ddbd |
|
MD5 | 726992777a05fd20df3eeb51c18c94d5 |
|
BLAKE2b-256 | 925763fa79fc5534cb21a08ef94716e569f431562500f25f9877bfe35636d7e6 |
Hashes for datasette_leaflet_freedraw-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aec44f67d678266fad157a7f0728f76289696c44fd6814de881461658ae2e0ce |
|
MD5 | 678d2d5866becc0f3baf84f96740447c |
|
BLAKE2b-256 | fa730143e8b7802f9bbc629010da2c102b51f5d32c19c44bf3d89fc17c7eef9d |