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

Using QGIS, I have a layer with 100 towns. I have another layer with 200 cycle routes, each with a different name. I want to create (automatically natch) a table that will help the people in each town, for example, get a list of all of the routes that pass within 1Km of their town centre.

share|improve this question

If you bring your layers into Spatialite, here's a one-liner to get what you want:

SELECT, b.Trail_Name FROM towns AS t, bike_trails AS b
WHERE ST_Intersects(b.Geometry, BUFFER(t.Geometry, 1000));

This query will select each bike_trail name from the bike_trails layer which passes within 1000 m of a town, and list all the town ID's with each trail name.

share|improve this answer
+1 Nice solution! You might want to add some brief instructions on how to do an SQL query on a spatialite layer within QGIS. Would you use the Spatialite Manager plugin, for example? – Simbamangu May 14 '12 at 5:08
Thanks. I'd probably use the DBManager plugin within QGIS. Other wise spatialite_gui. – Micha May 19 '12 at 15:24

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.