[OSM-dev] Visualization of OSM data - objects without specific nearby object
Michał Brzozowski
www.haxor at gmail.com
Mon Apr 1 22:16:02 UTC 2019
Hi Mateusz,
Overpass API has already built-in functionality to search for such cases.
See:
https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_API_by_Example#Banks_far_away_from_police_stations
It's also possible to do so with PostGIS, but keeping in mind a few caveats:
- Don't use ST_Buffer, even if it seems natural (for me it did first time)
- it will unnecesarily generate a geometry. Use an anti-join along the
lines of:
SELECT id, someColumn, geom FROM table a LEFT JOIN table b ON
ST_DWithin(a.geom,b.geom,20) AND b.field = bCondition WHERE b.id IS NULL
and a.anotherField = aCondition
- Obviously Mercator meters are shorter, you can either compensate for the
average if your region of analysis is small, or use Mapbox's helper
MercDWithin, or use national coordinate system (e.g. EPSG:2180) when
importing with osm2pgsql.
- The above query relies on spatial indexes, for larger sets you can try to
get better performance by dumping A and/or B sets into tables or
materialized views (beware, these need to be refreshed manually) and
creating a spatial index on them.
Hope this helps.
Michał
On Mon, Apr 1, 2019 at 10:49 PM Mateusz Konieczny <matkoniecz at tutanota.com>
wrote:
> Is anyone aware about tool that takes as input two sets of OSM tags and
> will output
> visualization of data split into two groups
>
> - objects with tags from set A, more than X meters from any object with
> tags from set B
> - objects with tags from set A, no more than X meters from any object with
> tags from set B
>
> ?
>
> For example
>
> - highway=bus_stop for set A
> - highway=service/residential/unclassified/tertiary/... for set B
> - 20m as distance parameter
>
> This one would allow to list bus stops that are suspiciously far away from
> roads.
>
> In my case it would be "public objects without nearby bicycle parkings".
> --------
> Though, given that it seems to be build from 4 relatively simple steps it
> is likely that
> nobody who did it bothered to publish any part as a project.
>
> But if anyone see something stupid in my plan below - let me know!
>
> All parts of that are fairly easy
>
> - build list of tags indicating major public objects (shop=*,
> amenity=place_of_worship,
> amenity=restaurant, amenity=pharmacy, amenity=bar etc) [1]
> - download data [2]
> - run query to find public objects with/without nearby bicycle parkings [3]
> - generate visualization depicting this data [4]
>
>
> https://github.com/Leaflet/Leaflet.markercluster
>
> [1] is fairly simple, just go through preset of Vespucci or some other
> editor
> (though if anyone knows about listing of such tags - let me know)
> [2] probably just download extract of some region and load into database
> [3] postgis queries (ST_Buffer to build areas + ST_Within)?
> Though it would get fun if I would start looking for
> "bicycle parking within X meters from entrance to a public object"
> [4] https://github.com/Leaflet/Leaflet.markercluster for an initial
> version looks good enough
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20190402/8aef0847/attachment.html>
More information about the dev
mailing list