Sunday 18 February 2018

What are the pros and cons of PostGIS geography and geometry types?


My company uses geometry (the_geom) data type for storing geospatial data.


I've recently been acquainted to the concept of geography (the_geog) data type which, as I understand it, stores the SRID along with the geometry.


What are the differences between geography and geometry, and is there any advantage of using one of them in large databases?



Answer




Geography features are always stored in WGS84 prior to PostGIS 2.2; since then any lon/lat-based spatial reference system can be used. Measurements based on geography features will be in meters instead of CRS units and PostGIS will use geodetic calculations instead of planar geometry.


No all functions support geometry but you can cast between geometry and geography. For the current function list see: https://postgis.net/docs/PostGIS_Special_Functions_Index.html#PostGIS_GeographyFunctions


I don't think it's possible to recommend either geography or geometry for large databases. It depends on what you are doing with your data. As calculations on the sphere are more complicated, I'd expect analyses to be slower on geography features. You also have to transform all your data to WGS84 to use geography.


If you do a lot of measurements and e.g. have to compare sizes of large polygons, it would make sense to use geography rather than geometry.


I found the following useful: http://postgis.net/workshops/postgis-intro/geography.html


The topic is also covered in "PostGIS in Action" (ISBN: 9781935182269).


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...