Rolls up a geographic grid or an array of geographic grids to a coarser aggregation level.
Syntax
geomgrid ST_Generalize(geomgrid gridcode, integer precision);
geomgrid[] ST_Generalize(geomgrid[] gridarray, integer precision, bool degenerated default false);Parameters
| Parameter | Description |
|---|---|
gridcode | The geographic grid object to aggregate. |
gridarray | The array of geographic grids to aggregate. |
precision | The target aggregation level. |
degenerated | Specifies whether to use a degenerated grid. Defaults to false. |
Description
ST_Generalize aggregates a geographic grid or an array of geographic grids to a lower aggregation level (coarser resolution).
For the array overload, all grids in the input array are aggregated to the specified precision.
Examples
Aggregate a single grid to a lower precision
The following example aggregates grid GZ0026206440 (precision 10) to precision 5. The output grid GZ00262 covers the area of the original grid at a coarser resolution.
SELECT ST_AsText(ST_Generalize(ST_GridFromText('GZ0026206440'), 5));Result:
st_astext
-----------
GZ00262Aggregate an array of grids derived from a 3D geometry
The following example generates a geomgrid[] from a 3D line string at precision 10, then aggregates all grids to precision 8.
SELECT ST_Generalize(ST_As3DGrid(
'srid=4490;LINESTRING Z (116 39 2000,116.012 39.009 3000)'::geometry, 10), 8);Result:
st_generalize
---------------------------------------------
{01024008722600000000,01024008742600000000}See also
ST_GridFromText: Create a
geomgridobject from its text representation.ST_As3DGrid: Generate a
geomgrid[]from a 3D geometry at a specified precision.ST_AsText: Convert a
geomgridobject to its text representation.