NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I've extracted some National Parks from Openstreetmap. But now I want to find out where the entrances are. Openstreetmap has some tags for it but it isn't used that often.

So I tought: An entrance into a national park is a road which crosses the border of that park. Must be true: You are going into the park. The only downside I can think off is that it could be a private road for staff or something but that should be a small percentage.

alt text

So what is the best ways to find these points?

My guess: I know the boundaries of the park. So I can download all roads in that park. Then I can use the "Ray casting algorithm" for all sections of all roads in the parks to see if it crosses a border. When it does: that is a road that goes into the park. However, that might be very slow. If you have a large park with lots of roads inside it, it might take ages to check all segments. Is there a more clever way?

asked 10 Aug '15, 11:23

NLAnaconda's gravatar image

accept rate: 0%

edited 10 Aug '15, 20:47

mmd's gravatar image


Here's an Overpass API solution for it: it will find all ways, which intersect with boundary=national_park relations:

Try it in overpass turbo! link

Just navigate to the area you're interested in and hit "Run". There's no need for a local DB or any other download.

permanent link

answered 10 Aug '15, 15:01

mmd's gravatar image

accept rate: 37%

edited 10 Aug '15, 15:03

This works great!

One question: Some roads are the border/on the border. They light up as bordercorssing but some dont really go in the park. Is there a way to exclude these roads?

(10 Aug '15, 16:22) NLAnaconda

Can you please try the following query: - this one should exclude highways which are part of the boundary relation itself. A detailed explanation for this query can be found on the linked stackoverflow page.

(10 Aug '15, 20:40) mmd

I guess that some roads are on the boundary without being part of the boundary (like its an extra layer) Some are still highlighted. For example this one (north east) on Kruger National Park:

(10 Aug '15, 21:43) NLAnaconda

Way 327080110 seems to be on the border. However, if you zoom in a bit, you'll notice that it actually crosses the border somewhere near node 3337923111.. that's why this way is also included in the result.

(11 Aug '15, 10:10) mmd

You are right. Sorry. I think I can filter these roads out when I check if they have a node further into the parks.

(12 Aug '15, 00:35) NLAnaconda

You could filter an OSM data file (e.g. for the whole planet or a region you care about) using osmosis to only include roads and parks. Then import it into postgis with osm2pgsql, then use a standard ST_Intersection SQL query to find places where a park is crossed with a road. Internally it uses something like the 'ray casting algorithm', but you don't have to care about that.

I don't know how slow it is, depending on the size of the data, that might be fast enough.

permanent link

answered 10 Aug '15, 13:25

rorym's gravatar image

accept rate: 11%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 10 Aug '15, 11:23

question was seen: 4,766 times

last updated: 12 Aug '15, 00:35

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum