Ocean Queries

This guide showcases the basic syntax available within the Web Coverage Processing Service standard. Each example descibes the features being used and provides links to other resources were appropriate. You may also run the example directly from the page using the cog edit query image. If you wish to have a play with a particular query you can click the edit run query icon and the text will become editable (highlighted by the border turning green). You can then run the edited query by pressing the cog icon again.


Complex summarising

Users do not alwasy want to return imagery. This section showcases some simple real-world summerising queries over PML's data holdings.

creating a 1-D dataset of the true averages

This example creates a one dimensional csv dataset of the true averages for a given geospatial bounding box for every day in a years worth of data

for c in (CCI_V2_release_daily_chlor_a) return encode((float)
coverage histogram over
$px x( 0 : 0 ),
$py y( 0 : 0 ),
$pt ansi( 0 : 364 )
values  (
add( (c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)] < 100000 ) * c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)])
/
count(c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)] < 100000 )
)
, "csv")

creating a 3-day rolling average from daily chlorophyll data

This query uses the coverage constructor syntax shown previously [link] by looking ahead three daya and averaging we create a rolling 3-day average for us with traditional plotting techniques

for c in (CCI_V2_release_daily_chlor_a) return 
encode(
 (float) 
coverage histogram over 
$px x( 0 : 0 ),
$py y( 0 : 0 ),
$pt ansi( 0 : 361 ) 
values  (
add( (c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)] < 100000 ) * c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)]) 
/ 
count(c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt)] < 100000 ) +
add( (c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 1)] < 100000 ) * c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 1)]) 
/ 
count(c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 1)] < 100000 ) +
add( (c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 2)] < 100000 ) * c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 2)]) 
/
count(c[Long(-50:-40), Lat(45:55),ansi:"CRS:1"($pt + 2)] < 100000 ) 
)
, "csv")

Return the average chlorophyll concentration for a given area and a given time

This query uses built in avg() function to return a single value that represents the mean chloropyll concentration for a given bounding box

for c in ( CCI_V2_release_daily_chlor_a )
return 
encode((float)
 avg(
(c[Lat(0:10), Long(45:55), ansi:"CRS:1"(6)] < 100000) *
 c[Lat(0:10), Long(45:55), ansi:"CRS:1"(6)]

), "csv"

)

Utilising uncertainty

Along with our traditional data holding, the CCI datasets all have associated RMS and Bias uncertainty data. These data can be used in queries to generate some interesting results

Generating an average for the RMS uncertainty for a given area

This will feel similar to the average chloropyll query previously mentioned. That is because it is similar. With WCPS you will find yourself repeating many patterns and thus gerating a familiarity with the language.

for c in ( CCI_V2_monthly_chlor_a_rmsd )
return 
encode((float)
 avg(
(c[Long(0:10), Lat(45:55), ansi("2010-01-31T23:59:00")] < 10000) *
 c[Long(0:10), Lat(45:55), ansi("2010-01-31T23:59:00")]

), "csv"

)

Generating an average for chlorophyll in a given area where the uncertainty is below a certain threshold

This query shows the use of a conditional query over one coverage being applied to the selection of pixels from another coverage. This pattern becomes very useful for masking datasets prior to querying them.

for c in ( CCI_V2_release_chlor_a ), d in (CCI_V2_monthly_chlor_a_rmsd)
return 
encode((float)
 avg(
 c[Long(0:10), Lat(45:55), ansi("2010-01-31T23:59:00")] *
  (d[Long(0:10), Lat(45:55), ansi("2010-01-31T23:59:00")] < 0.1 )
 ), "csv"

)

counting the number of cells with a given uncertainty threshold

This is a good example to have a play with the live editing. click on the edit button and change the uncertainty threshold and run the query (using the cog icon). see what different thresholds do to teh answer.

for  d in (CCI_V2_monthly_chlor_a_rmsd)
return 
encode((float)
 count (d[Long(-10:10), Lat(45:55), ansi("2010-01-31T23:59:00")] > 0.1 ), "csv"

)