databasejsonopenstreetmappoint-of-interest

Get POIsdatabase


I create some project for travel but now I need database for beaches all over the world. is there some database of this type. Can I scraping from somewhere. Is it posible to get it from openstreetmap ?

I try with: http://poi.openstreetmap.nl/ but there is no this type of objects (POI)

Also I was try with google places but there is also havent this type...


Solution

  • Elements in OpenStreetMap are described by tags. For beaches there is the natural=beach tag.

    If you want to retrieve all beaches from OSM you can either use the Overpass APi and run a query for all elements having this tag or get the raw data (the planet or an extract) and run the query afterwards.

    The Overpass-XML query would look like:

    <osm-script output="json">
      <union>
        <query type="node">
          <has-kv k="natural" v="beach"/>
        </query>
        <query type="way">
          <has-kv k="natural" v="beach"/>
        </query>
        <query type="relation">
          <has-kv k="natural" v="beach"/>
        </query>
      </union>
      <recurse type="down"/>
    </osm-script>
    

    and the equivalent Overpass-QL query (which is just a compacter format):

    [out:json];(node["natural"="beach"];way["natural"="beach"];relation["natural"="beach"];);>;;
    

    You can either run this query directly to retrieve the raw data (it is also possible to retrieve XML instead of JSON) or show the result on OverpassTurbo.

    Note that this is a really heavy query as it involves checking the whole world, not just a particular geographic region (which could be achieved by specifying a bounding box). Hence the query will take some time to run and you might have to increase the timeout.

    A different approach is to download the planet or an extract you are interested in and use osmfilter to extract all elements with certain tags attached to them.