Blueprint for GIS Import/Export
XML
We need to be able to Import & Export these XML formats to/from the Database:
- GeoRSS (URL fetch/publish)
- Export done
- GPX (File upload/download)
- Export done
- KML (File upload/download & URL fetch/publish)
- Export done
- OSM (File upload/download)
- Import/Export done, but currently only a few Feature Classes mapped
- GML (? Low priority, not used much in real world)
Other formats which may be useful are Shapefiles, PostGIS & JSON.
These should be representations added to the RESTlike controller.
Rather than reinventing the wheel, we could consider wrapping FeatureServer to do a lot of this work for us (like Web2Py uses CherryPy) since it is WSGI-based.
Alternatively we could look to borrow code from it.
The XML conversion is probably best-done using XSL stylesheets:
Relevant XSDs:
- GeoRSS
- GPX
- GML
- KML
- OSM
Sahan Eden uses S3XRC for our XML Import/Export which uses lxml:
Other options are available:
- XML export from Web2Py: http://michaelangela.wordpress.com/2008/03/29/exporting-a-web2py-table-in-xml/
- KML export from Web2Py: http://groups.google.com/group/web2py/browse_thread/thread/b59bd3a9c40086f0
- PyRXP: http://www.reportlab.org/pyrxp.html
- Faster & optionally validating (DTD, XSD?), but requires compiling into Python so less portable (unless using pyexpat wrapper)
- PyRXP_Documentation.pdf
- XSD->DTD conversion (our schema are in XSD format)
- cElementTree - included in Python 2.5, strict & fast: http://effbot.org/zone/celementtree.htm
mytree=xml.etree.ElementTree.XML(request.body.read())
- sgmlop (supported by xmlrpclib): http://effbot.org/zone/sgmlop-index.htm
- pyexpat (non-validating & slower, but built-in to Python 2)
- Pyfo (example with Web2Py): http://michaelangela.wordpress.com/2008/04/10/simple-xml-creation-with-python/
- SAX: http://www.devshed.com/c/a/Python/Parsing-XML-with-SAX-and-Python/
CSV to KML Converter:
- http://code.google.com/apis/kml/articles/csvtokml.html
- Useful to extend to handle images (multiple images => Tabs)
This is another option for Import (via Python structures):
XML links:
- http://www.w3schools.com/Schema/schema_intro.asp
- http://diveintopython.org/xml_processing/index.html
- http://www.xml.com/pub/a/2002/09/18/py.html
- http://www.xml.com/pub/a/2003/09/10/py.html
Geotagged Photos
We should also be able to import Geotagged Photos & have these display on the Map.
Feature Metadata already includes an Image - so the work needed is just in terms of reading the Lat/Lon from the Tag & providing a UI:
Most developed OSS tools are:
- Exiv2 - C++ with pyexiv2 binding (still experimental)
- ExifTool - Perl (extra dependencies & needs to be run as system call)
- Comparison: http://www.picurl.org/development/wiki/Exiv2vsExifTool
Python works-in-progress here:
- http://sourceforge.net/projects/exif-py/?abmode=1
- http://www.ivan-herman.net/cgi-bin/blosxom.cgi/WorkRelated/SemanticWeb/xmpextract.html XMP-only
- http://code.google.com/p/python-xmp-toolkit/ XMP-only