Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am looking for the best way to run a visibility analysis in PostGis 2, i.e. given 2 points and obstacle polygons, are these 2 points visible from each other ?

I did not find anything relevant for now. Are you aware of :

  • such a function
  • a library I could use to perform this
  • or do I have to implement it by myself ?

Thanks in advance

share|improve this question
Not one which im aware, but SAGA has one , GRASS has one, QGIs has one in SEXTANTE toolbox. Probably easiest way would be use grass or saga from commandline to calculate it. Also i think all mentioned programs have open source – simplexio Mar 20 '13 at 11:33
Is this a 2D analysis? – Scro Mar 20 '13 at 12:20
Yes this is a 2d analysis – FredB Mar 20 '13 at 12:31
Why do you want to do it in PostGIS and not in a "real" GIS? If you were using (as mentioned) grass or QGIS, it would be very easy. – til_b Mar 20 '13 at 13:37
up vote 2 down vote accepted

You can do this with SQL. Without knowing how you're getting your data, I'd guess something like:

SELECT ST_Intersects([the polygon geom], ST_LineFromWKB([point A geom], [point B geom])) AS Is_Obscured

Obviously this is not a complete query. If it's not enough to point you in the right direction, then you'll need to share some more details.

share|improve this answer
It seems there is ST_3DIntersects. using that requires 3d data... But after reading that 2D comment i assume that Z dosent affect visibility – simplexio Mar 20 '13 at 12:59
I made the same assumption. Another assumption here is that the distances are short enough to ignore the whole geometry vs. geography great circle issue. – Scro Mar 20 '13 at 13:08
But then you can cast (or transform) geometry to geography (i think) – simplexio Mar 20 '13 at 13:15

Your Answer


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.