If you are using OSGeoLive, pycsw is already included. To check your current version:
$ sudo apt-cache show python-pycsw
To install pycsw on a fresh Ubuntu installation:
$ sudo apt-get install python-pycsw pycsw-cgi
This will also install dependencies (lxml, Shapely, pyproj, SQLAlchemy, OWSLib)
In order to upgrade pycsw to current stable version:
$ sudo apt-get install python-pycsw pycsw-cgi
To run the pycsw tester, use the pycsw launcher from the Web Services group, or open Firefox and navigate to http://localhost/pycsw/tester/index.html
By selecting the left drop-down list, the user can see various predefined POST requests, encoded as XML, that can be sent to pycsw:
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:
By selecting “GetCapabilities-SOAP” and pushing the “Send” button, a SOAP request is sent to the server to advertise their web service capabilities:
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:
By selecting “GetRecords-filter-anytext” and pushing the “Send” button, a full text search request is sent to the server:
The user can go through all the available requests and perform various requests from this testing application.
The capabilities of the pycsw installation can be found at http://localhost/pycsw/csw.py?service=CSW&version=2.0.2&request=GetCapabilities.
pycsw’s runtime configuration is defined by default.cfg. pycsw ships with a sample configuration (default-sample.cfg).
To edit the web service metadata, included in the capabilities document, the user can modify the file /var/www/pycsw/default.cfg under the tag [metadata:main].
[metadata:main]
pycsw supports the following databases:
In order to create a new SQLite database we need to:
[repository]
$ cd /var/www/pycsw
$ export PYTHONPATH=`pwd`
$ sudo python ./sbin/pycsw-admin.py -c setup_db -f 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
Note
Don’t forget to test the configuration by sending a GetCapabilities request to the pycsw server.
We will use some demo GIS data from the GeoNode project. The following will download the data archive and load all metadata xml files into our new database.
$ cd ~
$ wget https://github.com/GeoNode/gisdata/archive/master.zip
$ unzip master.zip
$ cd /var/www/pycsw
$ sudo ./sbin/pycsw-admin.py -c load_records -f default.cfg -p ~/gisdata-master/gisdata/metadata/good -r
Metadata files for a spatial dataset or a spatial web service can be created with a plain XML editor. Usually a specialized application is used to create metadata XML files, e.g. 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.
After the user has added all the information available, must push the validation button on top of the page, so that a check to be performed for consistency with the INSPIRE directive.
After a sucessful validation, the XML file can be saved to the local disk and viewed through a text editor or a browser.
Metadata editing alternatives include:
Note
Try to create new XML files and then try to load them into the pycsw server as shown previously.
We can harvest a working WMS service with the following:
<?xml version="1.0" encoding="UTF-8"?>
<Harvest xmlns="http://www.opengis.net/cat/csw/2.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/cat/csw/2.0.2 http://schemas.opengis.net/csw/2.0.2/CSW-publication.xsd" service="CSW" version="2.0.2">
<Source>http://webservices.nationalatlas.gov/wms/1million</Source>
<ResourceType>http://www.opengis.net/wms</ResourceType>
<ResourceFormat>application/xml</ResourceFormat>
</Harvest>
Save the file to something like “post.xml” and run:
$ cd /var/www/pycsw
$ python ./sbin/pycsw-admin.py -c post_xml -u http://localhost/pycsw/csw.py -x ~/post.xml
Note
In order to enable Harvesting, you need to edit default.cfg and set transactions=true.
Note
For transactions to be functional when using SQLite3, the SQLite3 database file (and its parent directory) must be fully writable. For example:
$ mkdir /path/data
$ chmod 777 /path/data
$ chmod 666 test.db
$ mv test.db /path/data
For CSW-T deployments, it is strongly advised that this directory reside in an area that is not accessible by HTTP.