Search code examples
rubyopenstreetmapgeocoder

How to find natural places in openstreetmap with geocoder gem for ruby


Im using the geocoder gem for ruby. I want to find natural places in openstreetmap in a given area (viewbox). Currently it looks like this:

Geocoder.search(q, params: {viewbox: viewbox, bounded: 1, limit: 20})

Where q is the search term. If I use q = '[school]' for example, I'm able to find all schools in the given viewbox. But How do I find natural places like woods etc.? I could use q = 'wood' but I want to avoid finding buildings or streets containing the word 'wood'.


Solution

  • Geocoders usually are intended for finding named places. To query for unnamed places of a specific type better use Overpass API instead and search for natural=wood (unmanaged woodland) and landuse=forest (woodland managed by humans). Example: https://overpass-turbo.eu/s/PDo

    Unfortunately I haven't used Overpass API with ruby myself so far however there is at least one ruby gem for this purpose: overpass-api-ruby.