How to get the POIS around a place

Hi all and thanks in advance for your help!

What I want to achieve:

Given a place (eg a town) I want to get a number of POIS around.

The word around is very important because I know that

  1. I can use /v2/directions/{profile}
  2. insert a single pair of coordinate for my place
  3. insert the round_trip option with a length
  4. Get the bbox value
  5. Use /pois
  6. Pass the previous bbox value
  7. Get the POIS

Problem is that the bbox calculated by /v2/directions/{profile} is not around my place, but it can be rendered only on north, only on south etc

How can I do?

Many thanks!

Davide

Hi @aminta,

check out the api-documentation for the /pois endpoint.

You can pass a GeoJSON to the pois endpoint and specify a buffer in meters around the geometry in which it should search for POIs.
Carefull with high buffer values though, depending on the area you are looking at, it might take a while to return all values.

If you use the /v2/directions/{profile}/geojson endpoint you can just use the route geometry and pass it to the pois service, like in the following example with a buffer of 20 meters:

{"request":"pois","geometry":{"buffer":20,"geojson":{"coordinates":[[8.681496,49.414601],[8.68147,49.414599],[8.681488,49.41465],[8.681423,49.415698],[8.681423,49.415746],[8.681427,49.415802],[8.681641,49.416539],[8.681656,49.41659],[8.681672,49.416646],[8.681825,49.417081],[8.681875,49.417287],[8.681881,49.417392],[8.682035,49.417389],[8.682107,49.41739],[8.682461,49.417389],[8.682563,49.417388],[8.682676,49.417387],[8.682781,49.417388],[8.683379,49.41738],[8.683595,49.417372],[8.683709,49.417368],[8.685294,49.417365],[8.685359,49.417365],[8.68535,49.41741],[8.685344,49.417457],[8.685299,49.417726],[8.685213,49.41827],[8.68503,49.419215],[8.685015,49.419256],[8.685094,49.419263],[8.686439,49.419404],[8.68651,49.419413],[8.686506,49.41943],[8.68651,49.419413],[8.687039,49.419467],[8.6871,49.419474],[8.687174,49.419482],[8.688301,49.419619],[8.688398,49.41963],[8.690104,49.419828],[8.690123,49.419833],[8.689854,49.420216],[8.689652,49.420514],[8.68963,49.42051],[8.688601,49.420393],[8.687872,49.420318]],"type":"LineString"}}}

Best regards

1 Like

Thanks @amandus for your prompt answer! In your example, if I have not misunderstood, you give to the endpoint a line, searching for POIS in a maximum distance of 20 meters. What I’m trying to achieve is, instead, given a single point (ie the center of a town), to get the POIS, filtered by category, in a given radius, say, of 20 maximum 30 km, so I can create a route to ride for example by bicycle…

Regards

you can do that by passing a point instead of the line with a buffer and also add the filter category to the request.
However, the maximum search radius is 2km.
So you either have to use the bbox after all and do multiple requests around the center
like this where x is your center and each rectangle is one bbox for a poi request.

.___.___.___.
|___|___|___|
|___|_x_|___|
|___|___|___|

or use a different strategy or service after all.

Best regards

1 Like

Thanks @amandus, maybe I can use the Overpass API to get the POIS in a radius of 15-30km and then pass the result to Openroute directions service…