../../_images/logo_pycsw.png ../../_images/OSGeo_project.png

pycsw Quickstart

pycsw is an OGC CSW server implementation written in Python. pycsw allows for the publishing and discovery of geospatial metadata. Existing repositories of geospatial metadata can be exposed via OGC:CSW 2.0.2 or OGC:CSW 3.0.0.

Running the tester application

To run the pycsw tester, use the pycsw launcher from the Web Services group, or open Firefox and navigate to http://localhost/pycsw/tests/index.html:

../../_images/pycsw_tester_startup.png

By selecting the left drop-down list, the user can see various predefined POST requests, encoded as XML, that can be sent to pycsw:

../../_images/pycsw_tester_selection.png

For example, by selecting “apiso/DescribeRecord”, and pushing the “Send” button, a description of the ISO Application Profile record is presented on the right panel:

../../_images/pycsw_tester_describe_apiso_record.png

By selecting “GetCapabilities-SOAP” and pushing the “Send” button, a SOAP request is sent to the server to advertise their web service capabilities:

../../_images/pycsw_tester_soap_capabillities.png

Also, the user can search for data records, performing a spatial bounding box query, by selecting “GetRecords-filter-bbox” and editing the coordinates in the XML request:

../../_images/pycsw_tester_getrecords_bbox_filter.png

The user can go through all the available requests and perform various requests from this testing application.

Capabilities Document and Configuration

The capabilities of the pycsw installation can be found at http://localhost/pycsw?service=CSW&version=2.0.2&request=GetCapabilities. If you just use http://localhost/pycsw you will get the capabilities document for CSW 3.0.0, since that is the latest version supported.

To edit the web service metadata, included in the capabilities document, the user can modify the file /etc/pycsw/default.cfg under the tag [metadata:main].

If the user wants to enable INSPIRE Discovery Service support, the metadata under the tag [metadata:inspire] has to be filled in and the enabled property has to be set to true.

For full functionality and configuration options, please consult the documentation on the pycsw website.

Metadata Creation

Metadata files for a spatial dataset or a spatial web service can be created through the open source implementation of inspire directive for metadata, European Open Source Metadata Editor (EUOSME). This application can be found at http://inspire-geoportal.ec.europa.eu/editor/. Source code is available at https://joinup.ec.europa.eu/svn/euosme/trunk

The user fills the mandatory metadata fields going through the application tabs, adding information like the name of the data owner, keywords, resource location on the web, geographic location (using a bounding box or the name of a country) etc.

../../_images/pycsw_euosme_metadata_input.png

After the user has added all the information available, they must push the validation button on top of the page, so that a check is performed for consistency with the INSPIRE directive.

../../_images/pycsw_euosme_save_metadata.png

After a successful validation, the XML file can be saved to the local disk and viewed through a text editor or a browser.

Loading Metadata

Metadata Repository Setup

pycsw supports the following databases:

  • SQLite3
  • PostgreSQL (PostGIS optional)
  • MySQL

In OSGeoLive, a simple SQLite setup has been implemented. The database can be found in /usr/share/pycsw/tests/suites/cite/data/records.db

Create new database

In order to create a new SQLite database we need to:

  1. Edit /etc/pycsw/default.cfg:

    [repository]

  2. Setup the database:

    $ sudo pycsw-admin -c setup_db -f /etc/pycsw/default.cfg
    

This will create the necessary tables and values for the repository.

The database created is an OGC SFSQL compliant database, and can be used with any implementing software. For example, to use with OGR:

$ ogrinfo /path/to/records.db
INFO: Open of 'records.db'
using driver 'SQLite' successful.
1: records (Polygon)
$ ogrinfo -al /path/to/records.db
# lots of output

Importing Metadata

$ sudo pycsw-admin -c load_records -f /etc/pycsw/default.cfg -p /path/to/records -r

This will import all *.xml records from /path/to/records into the new database and configure the repository to expose queryables as per Table 53 of OGC:CSW.

Data Discovery through QGIS MetaSearch Plugin

Start QGIS from the Desktop GIS group and click on the MetaSearch button (CSW icon)

../../_images/pycsw_qgis_metasearch_open.png

Add the pycsw server by pressing the “New” button and type in http://localhost/pycsw/

../../_images/pycsw_qgis_metasearch_add.png

The user can add some default servers using the “Add default servers” button and also get the capabilities of the server using “Server info” button

../../_images/pycsw_qgis_metasearch_server_info.png

Perform search using the catalogue, either by a string value or with a bounding box

../../_images/pycsw_qgis_metasearch_search.png

Things to try

  1. Try to discover data through the Tester application by setting the appropriate requests eg. any text search with the string “imagery” leads to discovering the xml data created previously by EUOSME
../../_images/pycsw_tester_discovery.png
  1. Try to discover data through the Python OWSLib CSW interface.
  2. Try to discover data from GeoNode, which is also included in OSGeoLive and uses pycsw as the default CSW engine.

What Next?

For more information on pycsw, please consult the documentation on the pycsw website.