Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am looking for a function that will return the intersection of 2 or more polygons (geography type).

I am aware of ST_UNION, ST_COLLECT but it works only for geometry type.

Any tip will be really appreciated

share|improve this question

2 Answers 2

You can cast to geometry and do the calculation. If your data goes over the poles or date-line that could be problematic. Also if you have long edges, in which the great-circle interpolation line differs from a simple cartesian interpolation. In those cases you might have to create your own aggregate function that re-projects to something reasonable before running the operation.

SELECT ST_Transform(
  ST_Union(ST_Transform(geog::geometry, 26910)),
  4326)::geography 
FROM the_table
share|improve this answer

According to bostongis, there is no UNION that works on geography type. So you have to first cast geography to geometry:

geometry(geography(your_table.the_geom))

Then apply ST_UNION and cast back.

share|improve this answer
    
Shouldn't data be projected first? Does other functions, like ST_Intersection, ST_Diffrence return correct results if data is geometry with srid WGS84. Perhaps it's good idea for separate question... –  stachu Aug 3 '10 at 7:01
    
Well, it depends on the extends of your data. As Paul already mentioned, problems at the poles and date-line occur if you don't use an appropriate CRS. –  underdark Aug 3 '10 at 20:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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