ZGIS/semantique

Spatial relational operators

Closed this issue · 2 comments

Description

In the current version we have already specific temporal relational operators (during, after and before) next to the regular relational operators (equal, greater, less, ..). These are meant for usage on arrays that have timestamps as their pixel values. Such arrays are obtained when extracting the time dimension coordinates from a spatio-temporal array. They are mainly useful when applying temporal filters.

Following the same idea, there should also be specific spatial relational operators that can be used on arrays that have x,y coordinate tuples as their pixel values. Such arrays are obtained when extracting the space dimension from a spatio-temporal array. They will mainly be useful when applying spatial filters.

The right-hand side in such a spatial relational expression would then be an object of class SpatialExtent which during query recipe construction can be referenced by e.g. sq.geometry() (just like sq.time_instant() and sq.time_interval() can already be used to reference TemporalExtent objects).

Spatial relational operators include:

  • intersects
  • disjoint
  • touches
  • contains
  • within
  • equals

An instruction using such expression could look like:

sq.entity("water").filter_space("intersects", sq.geometry(<geopandas object>))

Additional context

See here

Thanks @luukvdmeer for the initiative, we should continue investigating spatial analysis options and it's good to push it further. Just for clarification for me:

  • what is the geometry (geopandas object) in this case? Is it the area-of-interest that the user defines or is it derived from the data?

I would be happy to contribute to answer follow-up questions, e.g.

  • would the operations happen per timeslice or the entire extent (i.e., the union of all extents over time)?
  • are all pixels of an an entity treated as one object or are they grouped together, e.g., if there are two "blobs" of water pixels, one within, one intersects - what would be the output? (I remember some similar discussion some time ago where we began to differentiate between entity and instance for this purpose)?
  • What is touches in this context?
  • ...

The geopandas object is an area provided by the user, and should be a subset of the total AOI. In this way, it can be used to spatially filter pixels for a certain result, just as you can temporally filter pixels e.g. by keeping only those inside a certain year or month within the overall time span.

The intersects operators is implemented already (it uses the centroid of each pixel, i.e. pixels are filtered out if their centroid does not intersect with the provided area). For now I don't think it is needed to add more, lets first see if this feature is useful at all. Also note that this functionality is not "ported" to the Sen2Cube frontend, since we don't have a block to define spatial polygons.