Skip to content

ST_Analyze_Agg

Computes the statistics of geometries for the input geometry or geography.

Usage

struct ST_Analyze_Agg(geom: geometry)
struct ST_Analyze_Agg(geog: geography)

Arguments

  • geog (geography): Input geography
  • geom (geometry): Input geometry

Description

ST_Analyze_Agg() provides a high-level summary of its input geometries. The fields of its struct return type are:

  • count: Number of input geometries
  • minx, miny, maxx, maxy: Minimum bounding rectangle (envelope). For geography, this represents geographical bounds such that minx may be greater than maxx where this represents more compact bounds (e.g., a small feature crossing the antimeridian).
  • mean_size_in_bytes
  • mean_points_per_geometry
  • puntal_count: Number of point or multipoint geometries
  • lineal_count: Number of line or multilinestring geometries
  • polygonal_count: Number of polygon or multipolygon geometries
  • geometrycollection_count: Number of geometrycollection geometries
  • mean_envelope_width
  • mean_envelope_height
  • mean_envelope_area

Examples

SELECT ST_Analyze_Agg(
    ST_GeomFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)')
  ) AS analyze
┌──────────────────────────────────────────────────────────────────────────────┐
│                                    analyze                                   │
│                                    struct                                    │
╞══════════════════════════════════════════════════════════════════════════════╡
│ {count: 1, minx: 1.1, miny: 101.1, maxx: 10.1, maxy: 110.1, mean_size_in_by… │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT ST_Analyze_Agg(
    ST_GeogFromText('MULTIPOINT(1.1 101.1,2.1 102.1,3.1 103.1,4.1 104.1,5.1 105.1,6.1 106.1,7.1 107.1,8.1 108.1,9.1 109.1,10.1 110.1)')
  ) AS analyze
┌──────────────────────────────────────────────────────────────────────────────┐
│                                    analyze                                   │
│                                    struct                                    │
╞══════════════════════════════════════════════════════════════════════════════╡
│ {count: 1, minx: 1.0999999999999748, miny: 90.0, maxx: 10.100000000000025, … │
└──────────────────────────────────────────────────────────────────────────────┘