--- path: industries/engineering-and-infrastructure title: Engineering and Infrastructure desc: Count the buildings and assets inside a route corridor. date: Oct 21, 2026 --- # Count what a route corridor touches Route options are compared on what they touch. This example draws a 50 m corridor along Tbilisi's rail and metro lines and picks out every building inside it, from OpenStreetMap. ## Buildings within 50 m of Tbilisi's rail and metro lines **Data:** OpenStreetMap rail and metro lines, and buildings **Method:** keep every building within 50 m of a line, measured on the ellipsoid ```sql -- Buildings within 50 m of a rail or metro line WITH rail AS ( SELECT geom FROM osm.public_transport_line WHERE osm_type = 'railway' AND osm_subtype IN ('rail', 'subway') AND geom && ST_MakeEnvelope(44.70, 41.65, 44.90, 41.80, 4326) ) SELECT b.osm_id, b.osm_subtype AS building, b.name, b.geom FROM osm.building_polygon AS b WHERE b.osm_type = 'building' AND b.geom && ST_MakeEnvelope(44.70, 41.65, 44.90, 41.80, 4326) AND EXISTS ( SELECT 1 FROM rail AS r WHERE r.geom && ST_Expand(b.geom, 0.001) AND ST_DWithin(b.geom::geography, r.geom::geography, 50) ); ``` The geography cast makes `50` mean metres without choosing a projection. Most of these buildings carry no building type in OpenStreetMap, so a breakdown by type is partial. ```map tbilisi-rail-corridor-buildings ``` ## Run it on your data Upload your alignment as GeoJSON, Shapefile, KML or GPX and swap it in for the `rail` step; the corridor and the buildings it catches land as layers on the map. Replace the OpenStreetMap buildings with your own parcels or asset register the same way, and export the map to QGIS for detailed design work. See [supported files](/docs/upload-anything/files). ## Frequently asked questions **How precise is the corridor?** As precise as the route you upload and the projection used\. OpenStreetMap buildings are not survey data\. **Can I compare two alignments?** Upload both routes and run the same query against each\. The results land as separate layers\. ## Next step - [Open the map in the gallery](/gallery?industry=engineering-and-infrastructure) - [Why the projection matters](/docs/spatial-sql-book/04-srid-degrees-metres) - [Book a demo](/demo)