1+ from model import MultiBand
2+
13# Overview
24
35The [ OGC Web Coverage Processing Service (WCPS) standard] ( https://www.ogc.org/standards/wcps )
@@ -233,8 +235,9 @@ Other reduce methods include `sum()`, `max()`, `min()`, `all()`, `some()`.
233235
234236## Timeseries Aggregation
235237
236- A more advanced expression is the * general condenser* (aggregation)
237- operation. The example calculates a map with maximum cell values across all time slices
238+ A more advanced expression is the
239+ [ general condenser] ( https://rasdaman.github.io/wcps-python-client/autoapi/wcps/model/index.html#wcps.model.Condense )
240+ (aggregation) operation. The example calculates a map with maximum cell values across all time slices
238241from a 3D datacube between "2015-01-01" and "2015-07-01", considering only the
239242time slices with an average greater than 20:
240243
@@ -260,7 +263,9 @@ service.download(query, 'max_map.png')
260263```
261264
262265How about calculating the average of each time slice between two dates?
263- This can be done with a * coverage constructor* , which will iterate over all dates
266+ This can be done with a
267+ [ coverage constructor] ( https://rasdaman.github.io/wcps-python-client/autoapi/wcps/model/index.html#wcps.model.Condense ) ,
268+ which will iterate over all dates
264269between the two given dates, resulting in a 1D array of average NDVI values;
265270notice that the slicing on the time axis ansi is done with the "iterator" variable ` ansi_iter `
266271like in the previous example. The 1D array is encoded as JSON in the end.
@@ -328,6 +333,86 @@ plt.ylabel('Average')
328333plt.show()
329334```
330335
336+ ## Convolution
337+
338+ The [ coverage constructor] ( https://rasdaman.github.io/wcps-python-client/autoapi/wcps/model/index.html#wcps.model.Condense )
339+ supports also enumerating the cell values in place as a list of numbers.
340+ This allows to specify small arrays such as
341+ [ convolution kernels] ( https://en.wikipedia.org/wiki/Kernel_(image_processing) ) ,
342+ enabling more advanced image processing operation. The example below uses a
343+ [ Sobel operator] ( https://en.wikipedia.org/wiki/Sobel_operator )
344+ to perform edge detection on an image on the server, before downloading the result.
345+
346+ ``` python
347+ from wcps.service import Service
348+ from wcps.model import Datacube, Coverage, Condense, \
349+ AxisIter, CondenseOp
350+
351+ # kernels
352+ x = AxisIter(' $x' , ' x' ).interval(- 1 , 1 )
353+ y = AxisIter(' $y' , ' y' ).interval(- 1 , 1 )
354+ kernel1 = (Coverage(' kernel1' ).over([x, y])
355+ .value_list([1 , 0 , - 1 , 2 , 0 , - 2 , 1 , 0 , - 1 ]))
356+ kernel2 = (Coverage(' kernel2' ).over([x, y])
357+ .value_list([1 , 2 , 1 , 0 , 0 , 0 , - 1 , - 2 , - 1 ]))
358+
359+ # coverage axis iterators
360+ cov = Datacube(" NIR" )
361+ subset = [( " i" , 10 , 500 ), ( " j" , 10 , 500 )]
362+ cx = AxisIter(' $px' , ' i' ).of_grid_axis(cov[subset])
363+ cy = AxisIter(' $py' , ' j' ).of_grid_axis(cov[subset])
364+
365+ # kernel axis iterators
366+ kx = AxisIter(' $kx' , ' x' ).interval(- 1 , 1 )
367+ ky = AxisIter(' $ky' , ' y' ).interval(- 1 , 1 )
368+
369+ gx = (Coverage(' Gx' ).over([cx, cy])
370+ .values(Condense(CondenseOp.PLUS ).over([kx, ky])
371+ .using(kernel1[" x" : kx.ref(), " y" : ky.ref()] *
372+ cov.green[" i" : cx.ref() + kx.ref(),
373+ " j" : cy.ref() + ky.ref()])
374+ )
375+ ).pow(2.0 )
376+
377+ gy = (Coverage(' Gy' ).over([cx, cy])
378+ .values(Condense(CondenseOp.PLUS ).over([kx, ky])
379+ .using(kernel2[" x" : kx.ref(), " y" : ky.ref()] *
380+ cov.green[" i" : cx.ref() + kx.ref(),
381+ " j" : cy.ref() + ky.ref()])
382+ )
383+ ).pow(2.0 )
384+
385+ query = (gx + gy).sqrt().encode(" image/jpeg" )
386+
387+ service = Service(" https://ows.rasdaman.org/rasdaman/ows" )
388+ service.download(query, ' convolution.png' )
389+ ```
390+
391+ ## Case Distinction
392+
393+ Conditional evaluation is possible with
394+ [ Switch] ( https://rasdaman.github.io/wcps-python-client/autoapi/wcps/model/index.html#wcps.model.Switch ) :
395+
396+ ``` python
397+ from wcps.service import Service
398+ from wcps.model import Datacube, Switch, rgb
399+
400+ cov = Datacube(" AvgLandTemp" )[" ansi" : " 2014-07" ,
401+ " Lat" : 35 : 75 ,
402+ " Long" : - 20 : 40 ]
403+ switch = (Switch()
404+ .case(cov == 99999 ).then(rgb(255 , 255 , 255 ))
405+ .case(cov < 18 ).then(rgb(0 , 0 , 255 ))
406+ .case(cov < 23 ).then(rgb(255 , 255 , 0 ))
407+ .case(cov < 30 ).then(rgb(255 , 140 , 0 ))
408+ .default(rgb(255 , 0 , 0 )))
409+
410+ query = switch.encode(" image/png" )
411+
412+ service = Service(" https://ows.rasdaman.org/rasdaman/ows" )
413+ service.show(query)
414+ ```
415+
331416## User-Defined Functions (UDF)
332417
333418UDFs can be executed with the
0 commit comments