ternaustralia / auscover-api

Ubiquitous access to the TERN AusCover data services and resources
Other
3 stars 0 forks source link

Simple python wrapper for space/time/variable subsetting with GDAL (geotiff) and NCO (netcdf) #3

Open mpaget opened 8 years ago

mpaget commented 8 years ago

Define common parameters. Pass to GDAL and NCO depending on file type.

What output? Same as input type probably (different formats can be done by the reformatter)

mgnethery commented 8 years ago

Assorted thoughts from me.

The issue and possible solutions My initial problem to solve was to get a time-series for a single (latlon) point. I have also limited myself to thinking about two basic raster formats only (at this point): GeoTiff and netCDF. Various testing shows:

So, considering the above and wanting to minimise confusion in having too many ways to query various formats, I have now concentrated on getting time-series via two methods:

Python script Based on this, I have written a python script ( ts-request.py ). It requires a yaml file ( auscover-products.yaml ) as a store of the products we want to expose. I envisage that a future cataloguer/inventoriser/crawler will be the store of this information. For starters though, the "ts-request.py" script (run interactively) does:

WPS A further issue to solve was to be able to make this query available via as web processing service (so click on a map, it will pass the geo-location to this WPS process and return a (csv) time-series for that point). Still early days on this but have implemented WPS via a plugin for GeoServer (plus a python scripting plugin). Intention is this specific WPS process will call a python broker, which will then call the aforementioned ts-request script. A simple broker script is located ( here ). An example WPS URL that is currently working: http://qld.auscover.org.au/geoserver-dev/ows?service=WPS&version=1.0.0&request=Execute&Identifier=py:timeSeries&dataInputs=layer=5;lon_lat_position=[geojson-string]

Summary of GeoServer

mgnethery commented 8 years ago

Update: After much testing, Geoserver WPS plugin was too restrictive in not being able to specify metadata and default datatypes/mimetypes. Have now implemented the ZOO-project WPS service. This allows passing ComplexData, meaning geojson strings (eg. point location) can be passed to the WPS broker ( script ). A new example: http://qld.auscover.org.au/wps?Service=WPS&Request=Execute&Version=1.0.0&Identifier=timeSeries&dataInputs=layer=total_cover;lon_lat_position={%22type%22:%22FeatureCollection%22,%22features%22:[{%22type%22:%22Feature%22,%22geometry%22:{%22type%22:%22Point%22,%22coordinates%22:[149.00,-34.00,-2573.70]}}]}

mpaget commented 8 years ago

When selecting a grid from THREDDS' netcdfsubsetservice, it may fail with "unknown DataType == long". The reason is that somewhere in the backend ncss is choosing to write a netCDF3 files, which doesn't support the data type. The work-around would be to force a netCDF4 file to be written but not sure where this is would happen. Could submit an issue to https://github.com/Unidata/thredds.

The offending code will be somewhere near: thredds/tds/src/main/java/thredds/server/ncss/format The decision to write netcdf3 happens at or before: thredds/cdm/src/main/java/ucar/nc2/NetcdfFileWriter.java

mgnethery commented 8 years ago

Came across a very annoying issue which took ages to track down. It was specific to use of the rasterstats module (called by 'raster-stats.py').

Summary was I need to edit the file: /usr/lib/python2.7/ctypes/util.py", line 246, in _findSoname_ldconfig as per http://lists.osgeo.org/pipermail/zoo-discuss/2015-November/001382.html.