ckanext-dataspatial
⚠️ This extension is no longer maintained. (Archived on Nov 26, 2019)
A CKAN extension that provides geospatial awareness of datastore data.
Overview
NB: This extension is unmaintained. There have been some syntax updates so it should work with CKAN 2.8+, but it hasn’t been tested and is not currently in use by the Museum.
This extension provides geospatial awareness of datastore data. This includes:
- Geospatial searches within datasets
- Spatial extent of datastore searches
- Support for PostGIS
- Support for Solr via the ckanext-datasolr extension
Installation
- Clone the repository into the
src folder:
cd $INSTALL_FOLDER/src
git clone https://github.com/NaturalHistoryMuseum/ckanext-dataspatial.git
- Activate the virtual env and install requirements:
. $INSTALL_FOLDER/bin/activate
cd $INSTALL_FOLDER/src/ckanext-dataspatial
pip install -r requirements.txt
python setup.py develop
- Add ‘dataspatial’ to the list of plugins in your config file.
Configuration
# Backend for query_extent queries ('postgis' or 'solr'), default: postgis
dataspatial.query_extent = postgis
# WGS data field in PostGIS database, default: _geom
dataspatial.postgis.field = _geom
# Mercator field in PostGIS database, default: _the_geom_webmercator
dataspatial.postgis.mercator_field = _the_geom_webmercator
# For Solr (requires ckanext-datasolr)
dataspatial.solr.index_field = _geom
dataspatial.solr.latitude_field = latitude
dataspatial.solr.longitude_field = longitude
Actions
create_geom_columns: Creates PostGIS columns on a resource table
update_geom_columns: Updates geospatial columns when a row is updated
datastore_search: Supports filtering by WKT polygon using _tmgeom filter
datastore_query_extent: Returns geospatial extent of query results
Commands
# Create PostGIS columns
paster --plugin=ckanext-dataspatial dataspatial create-columns $RESOURCE_ID -c $CONFIG_FILE
# Create index
paster --plugin=ckanext-dataspatial dataspatial create-index $RESOURCE_ID -c $CONFIG_FILE
# Populate columns from lat/long
paster --plugin=ckanext-dataspatial dataspatial populate-columns $RESOURCE_ID -l $LATITUDE_COLUMN -g $LONGITUDE_COLUMN -c $CONFIG_FILE
Further Setup
PostGIS
Your PostgreSQL database must have PostGIS support installed.
Solr
Requires the ckanext-datasolr extension for Solr support.