Saturday 25 May 2019

What's the benefit of heterogeneous geometry column in PostGIS?



I read that in PostGIS, one can have different types of geometry, say, POINT and LINESTRING?? in the same column/field of a table.


I have used ESRI products a lot where each table can only contain one type of geometry. I am just curious what is benefit/motivation for allowing mixed geometry types in PostGIS columns?



To me, what PostGIS did is to have an array of Java ObjectS, which is kind of pointless, since an Object (or Geometry in the case of PostGIS) can be anything. We can't really reason much about the base class geometry (e.g. its dimension and inoperability with other entities etc.) because it's too abstract.


For example, polygons have no length, points have no meaningful lengths or areas (because points are often simplified representation of linear/areal objects). Naturally, one can't do statistics/aggregates such as finding out the average measure of a geometry field because a measure may not be defined for some rows, due to the lack of constraint on the specific type of the geometry.


Am I missing some beneficial aspects of the heterogeneous columns?


Also, are there any practical examples of hetergeneous columns for non-geometric types in Postgres? For example, a column that can be both float-ing point numbers and bytea, or is the mixed columns a PostGIS invention?



Answer



I will need to recheck my copy of "PostGIS in Action" by Regina Obe and Leo Hsu (Great book).


Basically it lists the pro's as:



  • It allows you to run a single query of several feature of interest without giving up the luxury of modeling them with the most appropriate geometry type

  • It's simple. you could cram all your geometries into one table if their non spatial attributes are more or less the same.


  • Table creation is quick because you can do it by setting the field as a geometry with a single create table statement and not have to worry about additional need to apply the AddGeometryColumn function, great if you are importing lots of tabulated data


If you can get hold of the book I highly recommend it. It is getting a bit old now and some functions may have changed.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...