Changes between Version 2 and Version 3 of PetascopeSubsets


Ignore:
Timestamp:
Feb 28, 2014, 10:40:19 AM (11 years ago)
Author:
Piero Campalani
Comment:

first section

Legend:

Unmodified
Added
Removed
Modified
  • PetascopeSubsets

    v2 v3  
    11= Subsets in Petascope =
    22
    3 This page serves as reference point for the conclusions that have been reached in the discussion '''rasdaman-users::Subsets and pixel-domain indexes''' (''Alan'', ''Peter'', ''Stephan'', ''Marcus'' and ''Piero'' | July 2012), regarding how subsets should be interpreted by Petascope.
     3In this page we will describe how subsets (trims and slices) are treated by ''Petascope''. Before this you will have to understand how the topology of a grid coverage is interpreted with regards to its origin, its bounding-box and the assumptions on the sample space. Some practical example will then be proposed.
     4
     5
     6== Geometric interpretation of a coverage
     7
     8This section will focus on how the topology of a grid coverage is stored in the metadata database and how Petascope interprets it.
     9For point-clouds (multipoint coverages, in the GML realm), the subject is straightforward: each point is a 0D element (please not that bbox description of point-clouds are currently not implemented: see #571).
     10
     11When it comes to the so-called ''domainSet'' of a coverage (hereby also called domain, topology or geometry), the metadata database (`petascopedb`) follows pretty much the GML model for rectified grids: the grid origin and one offset vector per grid axis are enough to deduce the full ''domainSet'' of such (regular) grids. When it comes to referenceable grids, the ''domainSet'' still is kept in a compact vectorial form by adding weighting coefficients to one or more offset vectors. For more on this please refer to the [PetascopeUserGuide user guide].
     12
     13 ''What is a grid? :: As by [http://www.opengeospatial.org/standards/gml GML standard] a grid is a ''network composed of two or more sets of curves in which the members of each set intersect the members of the other sets in an algorithmic way''. The intersections of the curves are represented by points: a point is 0D and is defined by a single coordinate tuple and implements ISO:19107 `GM_Point` (see D.2.3.3 and ISO 19107:2003, 6.3.11).
     14
     15A first question arises on where to put the grid '''origin'''. The [https://portal.opengeospatial.org/files/?artifact_id=48553 GMLCOV standard] says that the mapping from the domain to the range (feature space, payload, values) of a coverage is specified through a function, formally a `gml:coverageFunction`.  We do not currently support the configuration of such function, whereas we stick to the default mapping which is indeed assumed when no coverage function is described. From the GML standard: ''If the `gml:coverageFunction` property is omitted for a gridded coverage (including rectified gridded coverages) the `gml:startPoint` is assumed to be the value of the `gml:low` property in the `gml:Grid` geometry, and the `gml:sequenceRule` is assumed to be linear and the `gml:axisOrder` property is assumed to be `+1 +2`''.
     16
     17To better understand this, the following image is showing the difference between a ''linear'' sequence rule (what we adopt) and an other kind of mapping, the so-called ''boustrophedonic'' [http://www.schemacentral.com/sc/niem20/e-gml_sequenceRule-1.html this] page for other available rules:
     18
     19[[Image(sequenceRules.png, center, 50%)]]
     20
     21In the imag, it is assumed that the first grid axis (`+1`) is the horizontal axis, while the second (`+2`) is the vertical axis; the grid starting point is the full diamond.
     22
     23Sticking to the linear sequence rule was the best choice for `rasdaman` since that is the same rule which `rasdaman` itself uses to print the values of cells in an collection/marray.
     24Coming back to the origin question on where to put the origin of our grid coverages, we have to make it coincide to what the starting value represents in `rasdaman`, the marray origin.
     25
     26As often done in GIS applications, the origin of an image is set to be its upper-left corner: this finally means that the origin of our rectified and referenceable grid coverages shall be there too in order to provide a coherent GML/GMLCOV coverage, where the domain is really mapped to the range of the coverage with the default coverage function. Note that placing the origin in the upper-left corner of an image means that the offset vector along the northing axis will point South, hence will have negative norm (in case the direction of the CRS axis points North!).
     27
     28When it comes to further dimensions (a third elevation axis, time, etc.), the position of the origin depends on the way data has been ingested. Taking the example of a time series, if the marray origin (which we can denote as `[0:0:__:0]`, though it is more precisely described as `[dom.lo[0]:dom.lo[1]:__:dom.lo[n]`) is the earliest moment in time, then the grid origin will be the easliest moment in the series, and the offset vector in time will point to the future (positive norm); in the other case, the origin will be the latest time in the series, and its vector will point to the past (negative norm).
     29
     30To summarize, in ''any'' case '''the grid origin must point to the marray origin'''. This is important in order to properly implement our linear sequence rule.
     31
     32A second question arises on how to treat coverage points: are they points or are they areas? The formal ISO term for the area of a point is '''sample space'''. We will refer to it as well as ''footprint'' or area.
     33The GML standard provides guidance on the way to interpret a coverage: ''"When a grid point is used to represent a sample space (e.g. image pixel), the grid point represents the center of the sample space (see ISO 19123:2005, 8.2.2)"''.
     34
     35In spite of this, there is no formal way to describe GML-wise the footprint of the points of a grid.
     36While the configuration of sample spaces is still just on the wishlist (see #680), our current policy applies distinct choices separately for each grid ''axis'', in the following way:
     37
     38   * ''regular axis'': when a grid axis as equal spacing between each of its points, then it is assumed that the sample space of the points is equal to this spacing (resolution) and that the grid points are in the middle of this interval;
     39   * ''irregular axis'': when a grid axis as an uneven spacing between its points, then there is no (currently implemented) way to either express or deduce its sample space, hence 0D points are assumed here (no footprint).
     40
     41Such policy translated in practice to a ''point-is-pixel-center'' interpretation of regular rectified images. The following art explains it visually:
     42
     43{{{
     44
     45  KEY
     46          # = grid origin             o = pixel corners
     47          + = grid points             @ = upper-left corner of BBOX
     48  {v_0,v_1} = offset vectors
     49
     50  |======== GRID COVERAGE MODEL =========|    |===== GRID COVERAGE + FOOTPRINTS =====|
     51
     52                                             {UL}
     53           v_0                                 @-------o-------o-------o-------o--- -
     54       -------->                               |       |       |       |       |
     55     . #-------+-------+-------+--- -          |   #   |   +   |   +   |   +   |
     56 v_1 | |       |       |       |               |       |       |       |       |
     57     | |       |       |       .               o-------o-------o-------o-------o-- -
     58     V |       |       |       .               |       |       |       |       .
     59       +-------+-------+--- -                  |   +   |   +   |   +   |       .
     60       |       |       |                       |       |       |       |
     61       |       |       .                       o-------o-------o-------o-- -
     62       |       |       .                       |       |       |       .
     63       +-------+--- -                          |   +   |   +   .       .
     64       |       |                               |       |       .
     65       |       .                               o-------o--- -
     66       |       .                               |       .
     67       +--- -                                  .   +   .
     68       .                                       .
     69       .             
     70                         
     71  |======================================|    |======================================|
     72}}}
     73
     74The left-side grid is the GML coverage model for a regular grid: it is a network of (rectilinear) curves, whose intersections determine the grid points `'+'`. The description of this model is what `petascopedb` knows about the grid.
     75
     76The right-hand grid is instead how ''Petascope'' inteprests the information in `petascopedb`, and hence is the coverage that is seen by the enduser. You can see that, being this a regular grid, sample spaces (pixels) are added in the preception of the coverage, causing an extension of the bbox (`gml:boundedBy`) of half-pixel on all sides. The width of the pixel is assumed to be equal to the (regular) spacing of the grid points, hence each pixel is of size `|v_0| x |v_1|`, being `|*|` the norm operator.
     77
     78As a final example, imagine that we take this regular 2D pattern and we build a series of such images on irregular levels of altitude:
     79
     80{{{
     81
     82  KEY
     83          # = grid origin             X = ticks of the CRS height axis
     84          + = grid points             O = origin of the CRS height axis
     85  {v_0,v_2} = offset vectors
     86
     87
     88      O-------X--------X----------------------------X----------X-----X-----------> height
     89      |
     90      |       ---> v_2
     91      |     . #________+____________________________+__________+_____+
     92      | v_0 | |        |                            |          |     |
     93      |     V +________+____________________________+__________+_____+
     94      |       |        |                            |          |     |
     95      |       +________+____________________________+__________+_____+
     96      |       |        |                            |          |     |
     97      |       +________+____________________________+__________+_____+
     98      |       |        |                            |          |     |
     99      V       .        .                            .          .     .
     100   easting
     101
     102}}}
     103
     104In `petascopedb` we will need to add an other axis to the coverage topology, assigning a vector to it, `v_2` (we support `gmlrgrid:ReferenceableGridByVectors` only, hence each axis of any kind of grid will have a vector). Weighting coefficients will then determine the height of each new z-level of the cube: such heights are encoded as distance from the grid origin `'#'` normalized by the offset vector `v_2`. Please note that the vector of northings `v_1` is not visible due to perspective: the image is showing the XZ plane.
     105
     106Regarding the sample spaces, while ''Petascope'' will still assume the points are pixels on the XY plane (eastings/northings), it will instead assume 0D footprint ''along'' Z, that is along height: this means that the extent of the cube along height will exactly fit to the lowest and highest layers, and that input Z slices will have to select the exact value of an existing layer.
     107
     108The latter wouls not hold on regular axes: this is because input subsets are targeting the sample spaces, and not just the grid points, but this is covered more deeply in the following section.
     109
     110
     111== input and output subsetting
     112
     113..open/closed intervals (we have closed now: reply to [https://groups.google.com/d/msg/rasdaman-users/3Zaz6snbtgU/KSsEj2oIqAIJ this] post in our mailing list to discuss this topic), output subsets (expressed via gml:Envelope) fit to mimimum bounding box: reduced area until is greater than a unit = pixel size.
    4114
    5115In general, pixel validity is meant as half open `[min,max)`, whereas the subsets are meant as closed intervals `[a,b]`.
    6116Subsets with extent smaller than a pixel resolution return the pixel(s) that include(s) it.
     117
     118== Examples
    7119
    8120This is probably better understood by means of examples: