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'd like to select some neighbor polygons with ST_Touches. Therefore I found the following statement:

FROM layera as a
JOIN layera as b
  ON ST_Touches((SELECT a.geom FROM layera as a WHERE = 5124),b.geom)

With this I get all the neighbor polygons of the polygon with the id '5124'. But now I want to call this function with a list of arguments. See the example statment below:

FROM layera as a
JOIN layera as b
  ON ST_Touches((SELECT a.geom FROM layera as a WHERE > 5000),b.geom)

(SELECT a.geom FROM layera as a WHERE > 5000 returns lets say 100 results)

I know that this won't work because ST_Touches works for only two arguments. But this should show what I'd like to do. How is it possible to insert all the results of a SELECT-statement into this ST_Touches function?

Thanks for any suggestions. =)


Ok, I just found out that I get the same result set with this statement:

FROM layera
WHERE ST_Touches(layera.geom,(SELECT layera.geom FROM layera WHERE = 5134)) 

Anyway, the problem isn't solved. =(

share|improve this question
up vote 3 down vote accepted

If I understand you right, you have just complicated the syntax a little:

layera AS a INNER JOIN layera AS b 
ON ST_Touches(a.geom, b.geom)! AND < 5000;

Then you will get a list of all combinations between the first 4999 numbers and the rest.

share|improve this answer
Thank you so much. This solved my problem. I can actually remove the WHERE! because it returns the same result set as with it. – Chronnie Jun 3 '13 at 14:36

This is how I got around it

select *
from polygon
where st_disjoint( ( select polygon from polygons where id=1), neighbourhoods.polygon) =0

See more details here

share|improve this answer

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.