This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

How do I create polygons from OSM data?

0

Hi, I just discovered OSM files, and I think it awesome ! I am a cg artist. I use a software called Houdini, in which I would like to import osm data.

I have a python script doing excatly that. I read osm datas fine. But the problem is : I can't really make sens of all the different nodes in the file. The only paramters that make sense to me are the one containing some coordinates. I have been able to loop through them, creating a point each time. And I can se a result. All the points start to draw the shape of some streets.

So I am getting the data, no problem about that I think.

My question is : How are these points related to each other ? How can I make sense of them enough to be able to connect them ? My final goal is just to able to connect these points to represent streets and roads,but not necesserally in a very realistic way. I mean, all I really need is an order in which to connect points, and some infos about which point belongs to which way or road.

I hope I am being clear ?

asked 24 Jun '13, 23:38

gui2one's gravatar image

gui2one
56116
accept rate: 0%

edited 25 Jun '13, 00:56

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


3 Answers:

3

I think I've got it, I didn't seen the <way/> nodes with <nd ref="something ..."/> "ref" attribute corresponding to the id of the points I managed to loop through ... I must not be far from my goal ^^

answered 25 Jun '13, 00:40

gui2one's gravatar image

gui2one
56116
accept rate: 0%

3

Docu for .osm files might help you. Frederik's answer over there too.

answered 25 Jun '13, 00:54

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554
accept rate: 18%

Thank you, I get that part now ^^ . The rest of the job is python and me I guess. I have to write some nice lines of code to process this data. And there's potentialy A LOT of data ^^

I'll try to comment on my progress ^^ thanks for your help

G

(25 Jun '13, 02:26) gui2one
2

Okay, fine! I think you could write an entry about your progress with OSM-derived artwork in your user blog if you want to. At least I would be interested.

By the way: Please don't forget to attribute OSM and mention the OSM license if you publish your works, so others know where you got that great, open, free geo data from. :-)

(25 Jun '13, 03:14) aseerel4c26 ♦

hello, well I tried to post an entry in my blog. But the formatting is awfull. I posted my ptyhon code, and it's just unreadable. There seems to some formatting "commands". I am not familiar with that.

(25 Jun '13, 04:15) gui2one
1

It's Markdown. It does take a bit of getting used to...

(25 Jun '13, 07:39) SomeoneElse ♦

0

If you r using osmosis to bring the data into a data base its quite easy coz osmosis create the line strings for the ways then u can simply use

insert into polygons (select id,ST_MakePolygon(linestring) from ways where nodes[1]=nodes[array_upper(nodes,1)]);

command to create polygons from them

answered 04 Jan '16, 06:23

Ballaji%20R's gravatar image

Ballaji R
1
accept rate: 0%

Source code available on GitHub .