ODN Manual 1.0.0 wip

Table Of Contents

Previous topic

Harvester plugin

Next topic

Installing views

This Page

Spatial plugin

The spatial plugin allows CKAN to harvest spatial metadata (ISO 19139) using the CSW protocol.

DB configuration

Add the spatial extension to the ckan DB:

# su - postgres -c "psql ckan"
ckan=# CREATE EXTENSION postgis;
ckan=# GRANT ALL PRIVILEGES ON DATABASE ckan TO ckan;
ckan=# GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO ckan;

You can check the installed PostGIS version by using:

SELECT postgis_full_version();

Installing spatial libs

As root install the needed geos libs (needed for compiling Shapely):

yum install geos-devel geos-python

Installing ckan spatial

As user ckan:

. default/bin/activate
cd /usr/lib/ckan/default/src
git clone https://github.com/ckan/ckanext-spatial.git
cd ckanext-spatial
pip install -e .
pip install -r pip-requirements.txt

Init spatial DB

Init database, where 4326 is the default SRID:

(pyenv)$ cd /usr/lib/ckan/default/src/ckan
(pyenv)$ paster --plugin=ckanext-spatial spatial initdb 4326 --config=/etc/ckan/default/production.ini

Config

Edit file /etc/ckan/default/production.ini and add the spatial related plugins:

ckan.plugins = [...] spatial_metadata spatial_harvest_metadata_api spatial_query csw_harvester

You may also specify the default SRID:

ckan.spatial.srid = 4326

Add the info to display a WMS base layer in the extent map:

ckanext.spatial.common_map.type = wms
ckanext.spatial.common_map.wms.url = http://pubblicazioni.provincia.fi.it/geoserver/sfondi/service=wms
ckanext.spatial.common_map.wms.layers = SfondoCercoLight
ckanext.spatial.common_map.wms.styles =
ckanext.spatial.common_map.wms.format = image/png
ckanext.spatial.common_map.wms.srs =
ckanext.spatial.common_map.wms.version = 1.1.1
ckanext.spatial.common_map.wms.attribution =

Metadata validation

You may force the validation profiles when harvesting:

ckan.spatial.validator.profiles = iso19139,gemini2,constraints

CKAN stops on validation errors by default. If you want to import also metadata that fails the XSD validation you need to add this line to the .ini file:

ckanext.spatial.harvest.continue_on_validation_errors = True

This same behavior can also be defined on a per-source base, setting continue_on_validation_errors in the source configuration.

WMS resources validation

When importing data, the spatial harvester can optionally check if the WMS services pointed to the resources are reachable and working. To enable this check, you have to add this line to the .ini file:

ckanext.spatial.harvest.validate_wms = true

If the service is working, two extras will be added to the related resource: verified as True and verified_date with the timestamp of the verification.

Installing geo view

As user ckan:

. default/bin/activate
pip install ckanext-geoview

Edit file /etc/ckan/default/production.ini and add the plugins:

ckan.plugins = [...] resource_proxy geo_view geojson_view wmts_view

Also make CKAN create default views for the geo resources:

ckan.views.default_views = [...] geo_view geojson_view wmts_view

Then set up the formats that should be handled by the geoview plugin:

ckanext.geoview.ol_viewer.formats = wms kml wfs gml arcgis_rest

Refer to the official geoview page for further details at https://github.com/ckan/ckanext-geoview