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

I want to create a tricky overpass query, but im not sure how to do it and im hoping someone knows the answer

I want to

  1. Find all counties in Norway (admin_level=4)
  2. Find all municipalities in these counties (admin_level=7)
  3. Find all place=farm in these municipalities
  4. Output a list of some sorts where its possible to separate the municipalities

I did try to create something in overpass-turbo, but it quickly became a mess and didn't output what I wanted


asked 08 Apr '18, 19:30

FredrikLindseth's gravatar image

accept rate: 13%

edited 08 Apr '18, 19:45

It's currently not possible to restrict an area query with an area, so it is necessary to use map_to_area calls to work down through the areas.

You can see at the top I've commented out the code to fetch all the admin_level 4 entities in Norway and instead just fetch 1 of them, because the script times out with more than 1. Anyway, this script emits the tags for each admin_level=4 and then emits the tags for each admin_level=7 and then any place=farm found within that admin_level=7. So processed as a stream, each farm will belong to the last seen county and municipality.

// rel([admin_level=4];
( rel[admin_level=4][name=Nordland];
  out tags;
    out tags;
    out center;

You can also look at for some discussion of how to fetch points with containing areas.

permanent link

answered 09 Apr '18, 19:32

maxerickson's gravatar image

accept rate: 32%

That worked very well! I changed the output to out number too, since that was what I really was after.

(12 Apr '18, 00:42) FredrikLindseth

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: 08 Apr '18, 19:30

question was seen: 3,468 times

last updated: 12 Apr '18, 00:42

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