Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

We just want to write some spatial queries for our PostGIS tables, but we can only write queries with geometry columni like (POINT(36 43). Assume that we have two columns like geom and name, we want write our queries with the point name.

select st_astext(geom) from table
where ST_DWithin (geom, 'POINT (36 43)', 100);

Any ideas about writing these kind of queries without using geometry?

share|improve this question
Not really sure what you are trying to do here? Can you explain it more please. – Nathan W Jul 3 '12 at 11:37
Thanks for your reply. For example i just want to use; select st_astext(geom) from table where ST_DWithin (name, 'pointone', 100); -- i want to use another column to make queries, rather than using geom column. – kaankalkan Jul 3 '12 at 15:46
Perhaps you need: SELECT ST_AsText(geom) FROM table WHERE ST_DWithin(geom, 'POINT (36 43)', 100) AND name='blabla'; – Micha Jul 4 '12 at 10:59
can i write any variables in point or linestrings like 'POINT(var1 var2)' or "var_about_point" instead of 'POINT(36 43)'? Consider that my variables should come from a related column in my tables. thanks fro answers – kaankalkan Jul 5 '12 at 10:20

You need to modify the "select" part of your SQL query, so you are selecting the "name" column:

select name, st_astext(geom)
from table
where ST_DWithin(geom, 'POINT (36 43)', 100);

I suggest to learn more about SQL. There are many resources, for example here or 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.