Search code examples
google-bigquerygis

Why is a POINT a geography but a collection is a Geometry?


Why is the classification of multiple geographies a geometry type? For example:

SELECT ST_GeogFromText('POINT(0 1)') AS geography UNION ALL
SELECT ST_GeogFromText('GEOMETRYCOLLECTION(MULTIPOINT(-1 2, 0 12), LINESTRING(-2 4, 0 6))')

In other words, the string itself is GEOMETRYCOLLECTION instead of GEOGRAPHYCOLLECTION or FEATURECOLLECTION. Why is that so?


Solution

  • These things come from different standards / industry practices.

    First, the spatial concepts and their WKT names like POINT and GEOMETRYCOLLECTION come from OGC and SQL/MM standards:

    These standards describe spatial objects, and define WKT representation for POINT, LINESTRING, POLYGON, GEOMETRYCOLLECTION.

    Second, once users realized the planar world of GEOMETRY type is not enough, various databases invented ways to handle spherical / geodesic geometries. The most popular way the industry uses to define spherical geometry is a different SQL type GEOGRAPHY. Note that GEOGRAPHY is not a standard thing, but rather a common industry practice. Some databases, like MySQL, does not use GEOGRAPHY type, but use spherical math with geographic SRID. Anyway, when GEOGRAPHY type is written to WKT, it still uses GEOMETRYCOLLECTION name for compatibility. So GEOGRAPHY comes from SQL type, GEOMETRY from WKT standard.

    Finally, FeatureCollection is used sometimes to represent sets of object that have a geometry property and additional properties, e.g. in GeoJson format. You'll rarely see it used with SQL databases - the FeatureCollection simply corresponds to a table.