--- path: industries/retail title: Retail desc: Find the homes with no supermarket within 1 km. date: Oct 21, 2026 --- # Find the neighbourhoods no supermarket serves Grocery expansion teams look for homes with no store within reach. This example finds every residential building in Lisbon more than 1 km from a supermarket, from OpenStreetMap. ## Lisbon homes more than 1 km from a supermarket **Data:** OpenStreetMap supermarkets, mapped as points or outlines, and residential buildings **Method:** keep residential buildings with no supermarket within 1 km, measured on the ellipsoid ```sql -- Residential buildings with no supermarket within 1 km WITH supermarkets AS ( SELECT geom FROM osm.shop_point WHERE osm_type = 'shop' AND osm_subtype = 'supermarket' AND geom && ST_MakeEnvelope(-9.28, 38.66, -9.05, 38.82, 4326) UNION ALL SELECT ST_Centroid(geom) FROM osm.shop_polygon WHERE osm_type = 'shop' AND osm_subtype = 'supermarket' AND geom && ST_MakeEnvelope(-9.28, 38.66, -9.05, 38.82, 4326) ) SELECT b.osm_id, b.osm_subtype AS building, b.geom FROM osm.building_polygon AS b WHERE b.osm_type = 'building' AND b.osm_subtype IN ('apartments', 'residential', 'house', 'semidetached_house', 'terrace', 'detached', 'dormitory') AND b.geom && ST_MakeEnvelope(-9.25, 38.68, -9.08, 38.80, 4326) AND NOT EXISTS ( SELECT 1 FROM supermarkets AS s WHERE s.geom && ST_Expand(b.geom, 0.013) AND ST_DWithin(b.geom::geography, s.geom::geography, 1000) ); ``` The supermarket search runs a little wider than the homes, so a shop just over the city edge still counts. ```map lisbon-homes-far-from-supermarkets ``` ## Run it on your data Upload your own stores, or your competitors', as a spreadsheet and swap them in for the `supermarkets` step to see which homes none of them reach. Change `1000` to test another distance. See [spreadsheets](/docs/upload-anything/spreadsheets). ## Frequently asked questions **Does a gap mean a good site?** Not by itself\. Distance is one input\. Demand needs data this example does not include\. **Is the 1 km measured along streets?** No, in a straight line\. Distance along streets needs a road network and a different method\. ## Next step - [Open the map in the gallery](/gallery?industry=retail) - [Upload your store list](/docs/upload-anything/spreadsheets) - [Learn the SQL behind it](/docs/spatial-sql-book) - [Book a demo](/demo)