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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file datasette-leaflet-freedraw-0.2.tar.gz.
File metadata
- Download URL: datasette-leaflet-freedraw-0.2.tar.gz
- Upload date:
- Size: 238.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f9e305fb847f468140714bb0e180f2126a41c3e2628ca098735bef8e8d6ddbd
|
|
| MD5 |
726992777a05fd20df3eeb51c18c94d5
|
|
| BLAKE2b-256 |
925763fa79fc5534cb21a08ef94716e569f431562500f25f9877bfe35636d7e6
|
File details
Details for the file datasette_leaflet_freedraw-0.2-py3-none-any.whl.
File metadata
- Download URL: datasette_leaflet_freedraw-0.2-py3-none-any.whl
- Upload date:
- Size: 237.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aec44f67d678266fad157a7f0728f76289696c44fd6814de881461658ae2e0ce
|
|
| MD5 |
678d2d5866becc0f3baf84f96740447c
|
|
| BLAKE2b-256 |
fa730143e8b7802f9bbc629010da2c102b51f5d32c19c44bf3d89fc17c7eef9d
|