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

Hello everyone.

I want to get the polygon(postgis polygon) which represents some administrative area, without using josm and etc. The main purpose is after that I can grab additional info about this polygon, for example : how many lines intersect it or how many special nodes are located in it. All this i want to do with postgis query's.

I read about planet_osm_rels table, which represents some closed areas. I found out such info:

way_off Offset to first way id in parts

rel_off Offset to first relation id in parts

parts List of node IDs, way IDs and relation IDs in this relation.

members Array of members and roles, format: {member1, role1, member2, role2, ...}. Members are represented by a letter denoting their type plus their ID

I expected something like polygon but failed. So what columns should i use to build up needed polygon in postgis ( It will be really fine to understand also how to make it)?

asked 15 Jan '12, 21:13

zzzzteph's gravatar image

accept rate: 0%

You will have it much, much easier if you can find your polygon in the planet_osm_polygon table (look for something with boundary=administrative, admin_level=..). There you already have a finished PostGIS geometry.

The difference is that planet_osm_rels will contain your relation even if it is broken or does not make a proper polygon for another reason.

permanent link

answered 15 Jan '12, 21:15

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

Oh thanks! I didn't look in this table. It has all what I needed.

(15 Jan '12, 21:32) zzzzteph

Ok, and what about names ? I've got with query sometimes about 5 or 10 same area name with same osm_id. How can I manage with this problem ?

(15 Jan '12, 21:42) zzzzteph

If the ID is negative then these are polygons created from a single multipolygon or boundary relation. This happens e.g. if you have a country with tons of islands and people have drawn a national boundary around each or something. You can of course collect them into a proper MULTIPOLYGON geometry in PostGIS, or you can try to select the largest, depending on what you want to do with it.

(15 Jan '12, 21:53) Frederik Ramm ♦

I want to select city districts , it can't be more than 1 polygon,as i think. Some areas have the same name and same negative osm_id.

(15 Jan '12, 22:02) zzzzteph

And what about same districts ( I mean names ) in different cities?

(16 Jan '12, 08:51) zzzzteph

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: 15 Jan '12, 21:13

question was seen: 7,176 times

last updated: 16 Jan '12, 08:51

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