Scripts in Bash and NodeJS for interacting with the Systemapic API
- Upload datasets to timeseries (aka a
cube) - Replace datasets in timeseries
...more to come!
- Clone this repository to your harddrive,
- Enter folder
- Run install script
like so:
git clone https://github.com/systemapic/api-scripts.git
cd api-scripts
./install.shCreate your own datacube.json file from datacube.json.template:
{
"title" : "Hallingdal Snow Cover - 2016",
"options" : {
"type" : "scf",
"dateformat" : "YYYYMMDD"
},
"datasets" : "/home/ftp/snow/datasets/2016/",
"masks" : [
{
"title" : "hallingdal",
"description" : "Nedbørsfelt: Hallingdalsvassdraget",
"geojson" : "/home/ftp/snow/masks/hallingdal/hallingdal.geojson",
"data" : "/home/ftp/snow/masks/hallingdal/hallingdal.scf.json"
},
{
"title" : "rjukan",
"description" : "Kraftverk",
"geojson" : "/home/ftp/snow/masks/rjukan/rjukan.union.geojson",
"data" : "/home/ftp/snow/masks/rjukan/rjukan.scf.json"
}
]
}Then run script:
./upload_datacube.sh datacube.json.
This will do the following:
- Create a cube
- Upload all rasters in folder
- Add all rasters to cube
- Create a project
- Add cube layer to project
You can replace datasets in a cube, by using the ./replace_datasets.sh script with the replace_datasets.json configuration:
{
"folder" : "/home/ftp_globesar/2016_02/",
"cube_id" : "cube-535a0ec3-8705-4215-8c94-8786b9680598",
"granularity" : "day",
"date_format" : "x_x_YYYYMMDD"
}Simply add the cube_id for the cube which you would like to replace datasets in, and the folder from which to upload data. The granularity option is used when comparing dates of datasets (see below for more info on date parsing). 'day' is appropriate for daily rasters. The date_format corresponds to the pre-defined functions created to parse date strings (see Date parsing below).
Then run script:
./replace_datasets.sh replace_datasets.json.
NB: Note that you may have to reload a couple of times in order to get the new datasets showing (work in progress).
Dates are added to metadata from filename.
Currently with these helper functions, where SCF_MOD_2014_001.tif is parsed to Jan 01 2014.
It's possible to implement your own date parser, and change this function call.
