1

Apologies if this has been asked before; I found some similar questions (this mailing list post was particularly interesting: https://lists.osgeo.org/pipermail/postgis-users/2008-June/020353.html) but nothing quite satisfied my curiosity.

I have a table containing WGS84 data for a bunch of multipolygons (very large ones; multiple countries in most cases). I want to know which one contains an arbitrary point (where the point is also in WGS84 lat/long).

I am not sure if the geometry or the geography type is best suited for this. I implemented it first using geometry and it seems to work for some spot checks. I tried it with geography as well, and it was orders of magnitude slower.

1) Is geometry acceptable for modeling this, or will it have trouble?

2) If there will be some error using geometry, what are the error characteristics and magnitude to expect? (For example, will there be issues near boundaries of adjacent multipolygons, etc.)

EDIT: Since ST_Contains doesn't work with geography columns, I guess ST_Intersects would be the closest thing?

  • 1
    For point-in-very-large-polygons I would recommend to use ST_Subdivide postgis.net/docs/ST_Subdivide.html. Read also gaia-gis.it/fossil/libspatialite/…. – user30184 Mar 3 at 11:55
  • 1
    generally speaking, the difference between both types is the underlying math; geometry works on planar cartesian algebra, geography on (slower, much more complex) spheroidal algebra. however, topology is unaffected by either type, spatial intersection pattern are the same; stick with geometry here, and consider geography for measurements with high precision demands. note: 'very large multipolygons' defeat the purpose of any index, and exponentially increase processing time per geometry, see @user30184's comment. – ThingumaBob Mar 3 at 13:01
  • 1
    Thanks for the feedback, guys! I am aware of ST_Subdivide, but I don't think it's necessary since the query runs in single digit milliseconds (with geometry; geography takes 10x as long). The table is overall only like 100MB. @ThingumaBob if you post your comment as an answer, I'll be happy to accept it. Thanks! – ianthetechie Mar 3 at 14:57
  • @ianthetechie I did, although I feel that it needs more detail and references to become a 'good answer'...I just don't have the time right now. – ThingumaBob Mar 5 at 14:24
0

Generally speaking, the difference between both types is the underlying math:

  • geometry works on planar cartesian algebra
  • geography on (slower, much more complex) spheroidal algebra

However, topology is unaffected by either type, and spatial intersection pattern are the same; stick with geometry here, and consider geography for measurements with high precision demands:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.