Asked • 03/19/19

In PostGIS how can I do an ST_Intersection() search with a GEOMETRYCOLLECTION Geography field?

I have a Postgres table "files" with a lat/lon location field of type `geography(GeometryCollection,4326)`. Right now the field only contains lat/lon polygons. I have succeeded in creating a gist index for the field and in doing a bounding box search with a search polygon: select fileid, file_name, ST_AsText(location) from files where location && ST_MakeEnvelope (-81.0, 22.0, -76.0, 27.0); But, I need to do a fully intersection search but I hit the restriction that `ST_Intersection()` does not accept a GeometryCollection. Maybe I could use `ST_Distance()` since I only need to know if a search area intersects a location area, not what the intersection area is. But I don't see any way to specify a spherical earth calculation, and that is probably all I need most of the time. I have been thinking about changing the field to a multipolygon since that would probably work. It looks like `ST_Distance()` will work for what I need to do. It accepts a GeometryCollection and actually will do spherical earth calculations.

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.