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.

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

1 Answer 1

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

SELECT t.id, 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

 
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.