352 | | |
| 354 | Returns a geometry that represents the point set intersection of the geometry and the raster. The raster is first polygonised using ST_AsPolygon(raster) and ST_Intersection(geometry, geometry) is then performed between the provided geometry and all the geometries resulting from the polygonisation of the raster. |
| 355 | |
| 356 | If the geometries do not share any space (are disjoint), then an empty geometry collection is returned. |
| 357 | |
| 358 | ST_Intersection in conjunction with ST_Intersects is very useful for clipping geometries such as in bounding box, buffer, region queries where you only want to return that portion of a geometry that sits in a country or region of interest. |
| 359 | |
| 360 | If you only want to compute the intersection between the convex hull of the raster without polygonising it to group of contiguous pixels sharing a common value, do: |
| 361 | |
| 362 | ST_Intersection(ST_ConvexHull(raster, 'WITHNODATA'), geometry) |
| 363 | |
| 364 | If you only want to compute the intersection between the shape of the raster without polygonising it to group of contiguous pixels sharing a common value, do: |
| 365 | |
| 366 | ST_Intersection(ST_Shape(raster), geometry) |
| 367 | |
| 368 | '''Implementation details''' |
| 369 | |
| 370 | This function should be implemented as a pl/pgSQL function (possibly only a SQL function) performing the intersection between the provided geometry and the table generated by ST_AsPolygon(raster). |
| 371 | |
| 372 | |