Background and strategic fit
One important feature of HEF Data Catalog should be the ability to do a spatial search. This extension provides not only a spatial search but also to expand the metadata fields to add the spatial boundary to a resource.
- Extending metadata adding the resource boundary:
- Manually: selecting one or multiple locations/boundaries using the map widget. The program will automatically convert it into valid GeoJSION geometries. Most importantly it can be drawn in a simple and complex geometrical shape.
Manually: typing a valid GeoJSION geometry
- Representing the spatial boundary for resources with the spatial field.
- Searching and filtering resources based on their locations and through the map widget
Installations and Requirements
To install ckanext-spatial on a production site:
Ubuntu 16.4 (PostgresSQL 9.3 and PostGIS2.1)
Install PostGIS:
sudo apt-get install postgresql-9.3-postgis-2.1
Run the following commands. The first one will create the necessary tables and functions in the database, and the second will populate the spatial reference table:
sudo -u postgres psql -d ckan_default -f /usr/share/postgresql/9.3/contrib/postgis-2.1/postgis.sql sudo -u postgres psql -d ckan_default -f /usr/share/postgresql/9.3/contrib/postgis-2.1/spatial_ref_sys.sql
Change the owner of spatial tables to the CKAN user to avoid errors later on:
sudo -u postgres psql -d ckan_default -c 'ALTER VIEW geometry_columns OWNER TO ckan_default;' sudo -u postgres psql -d ckan_default -c 'ALTER TABLE spatial_ref_sys OWNER TO ckan_default;'
Execute the following command to see if PostGIS was properly installed:
sudo -u postgres psql -d ckan_default -c "SELECT postgis_full_version()"
You should get something like:
postgis_full_version ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- POSTGIS="2.1.2 r12389" GEOS="3.4.2-CAPI-1.8.2 r3921" PROJ="Rel. 4.8.0, 6 March 2012" GDAL="GDAL 1.10.1, released 2013/08/26" LIBXML="2.9.1" LIBJSON="UNKNOWN" RASTER (1 row)
Install some other packages needed by the extension dependencies:
sudo apt-get install python-dev libxml2-dev libxslt1-dev libgeos-c1
Install the extension
Activate your CKAN virtual environment, for example:
ENV /usr/lib/ckan/default/bin/activate
Install the ckanext-spatial Python package into your virtual environment:
pip install -e git+https://github.com/ckan/ckanext-spatial#egg=ckanext-spatial
Install the rest of Python modules required by the extension:
pip install -r /usr/lib/ckan/default/src/ckanext-spatial/pip-requirements.txt
Restart CKAN. For example, if you've deployed CKAN with Apache on Ubuntu:
sudo service apache2 reload
Configuration options
Choosing a backend for the spatial search
User interaction and design
- Extending metadata adding the resource boundary:
Manually (typing): as an additional field, resource owner needs to add the field "spatial" and give a valid GeoJSION geometry
Manually (selecting): there already exists an additional field "spatial" and a map widget. Resource owner only needs to select one or multiple boundaries. The program will automatically convert it into valid GeoJSION geometries.
- Representing the spatial boundary
- Opening up a resource metadata with the spatial information, there exists one widget on the bottom of the resource page showing the exact location of that resource on a map.
- Searching and filtering resources based on their locations
- Users who want to look for specific resources from a special location can search it through the map widget by choosing a bounding box directly on the map.
Questions and Answers
Below is a list of Q&A from user sides:
Question | Answers |
---|---|
1. From where I can find the spatial boundary of my resource in GeoJSON format? | http://geojson.io/ |
Further steps
- Add a spatial widget in the metadata form by which a user can only draw the boundaries and the program automatically convert it into the correct format (instead of typing the geometry).
- Improve the geometry drawing.
- Upgrade Solr (at the moment v. 3.4.) to solr 8 and change the backend for the spatial search