OpenStreetmap Import

Using the template file, I enable the add-on, but when I import an .osm file, I still don’t get buildings. A map from my hometown yields only streets. A section of London is streets and one building, a map from New York only generates empties. Is this something going wrong with the .osm file, the template blend, or something I don’t understand?

This is a great script, and I’m really excited to see where it goes!

bobmiq: Please check the “Create tag list” option in the file-window when choosing the osm file and look if any building-tags are present. It might be that your osm data has other tags. If you like, please post the link of the area you are using by copying the “Permalink” (lower right corner) in the OSM map window.

I clicked the Create Tag List option, and two buildings were created! Where can I find the list of present tags? http://www.openstreetmap.org/?lat=38.8797&lon=-99.3192&zoom=13&layers=M

It’s in the internal Text “tags.txt”.

I’ve now Imported the area and there are indeed only two buildings in the data.
But I found out that my script handles the coordinates wrong in that hemisphere.
So If someone knows how to convert the projections correctly please tell. To see how I’m converting them currently please look here https://gitorious.org/osm2blender/osm2blender/blobs/master/io_osm/osm_types.py in line 375 (method getCoordinates).

littleneo: please delete some of your PMs from your inbox, as I can’t write you.

done :slight_smile:
testing your script, (I’m at the empty phase, but will test w/ your template)

mmm ok I get it to work after 5-6 tries, this really rocks !

Tip: when importing you can check “Create tag list” on the left in the file browser to get an internal Text called “tags.txt”

I can’t see the option… in the link you wrote in the first post and in the next link below.

it’s funny because in my script that (sometimes…) can read osm too (but don’t know if I published that one will check after that) it builds the different kind/widths of roads, corners, sidewalks, and not the buildings (made apart, relatively randomly). :rolleyes::smiley:

I think maybe it would be easier to use if your script worked in two steps :
. a first where you load the datas and analyse it to build some dictionnaries/lists, and the tag list, and with a first 3d generation made of visible perimeters and not empties, whatever it’s tagged or not,
. and a second where one could deal with the tags, where the user defines the material/kind of object that correspond to each tag found, with a refresh button.

(you use minidom ? the script goes by a dictionnary/lists phase or does it generate straight from the xml ?)

but don’t know if I published that one will check after that

ok… I remember why I did not published that one !
but in some case it worked :slight_smile:

I fiddeled around some with this and Openlayers and got a map tile server working: http://www.anzui.de/osm2blender/openlayers/

I’ve made a python script that renders out PNGs according to the slippy map tilenames (http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames) using data imported by the addon.

Just wanted to say that I’ve now teamed up with littleneo and we are trying to bring Blended cities and OSM2Blender together (in some way).

Expect something new and totaly differenct coming soon. Currently we are in planing phase discussing possible systems and data-structures. We are aiming for a flexible user friendly and expandable city engine that has the option to import osm data. Littleneo is already doing progress on an experimental base. I’ll have a go soon too.

As you can see in my previous post, I’ve setup an experimental Map tile server using the Javascript based Openlayers Framework to “browse” a Blender osm-map. I want to push this side project further to allow user friendly export of those osm-maps.

If someone want’s to join the fun, please write me a PM. =)

Ok What exactly is a “tag”. Some screenshots of the script in action would help immensely.

I’m sorry the answer took so long, but I’ve been busy with work and getting started with the Blended-Cities addon I’m collaborating with littleneo on. It will change the way you will create your cities (also from osm data), but it won’t change the meaning of tags for osm import.

In OSM you can tag anything, and you can add as many tags and any tags you want. Its called “free tagging”. A tag consists of the tag name (e.g. “building”) and a tag value (e.g. “residential”).
Now you need to know that in OSM you have only 3 data-types. You have nodes (points along the earth surface), ways (collection of nodes that form an outline or a path) and relations (creates relations between ways, nodes and more ways. e.g. A tram route). Now it depends what kind of tags are attached to a way or node, for a OSM map renderer to decide how it will look like. The same goes for osm2blender. You have to define a ruleset that describes what kind of tags, or tag combinations create what kind of geometry.

So you have to read about the tags used in OSM here: http://wiki.openstreetmap.org/wiki/Map_Features

In future osm2blender will come along with a preset library that covers the basic tags and will generate at least something.

If you are interested you can have a look at the new Blended-Cities Project here: https://github.com/littleneo/Blended-Cities

Can I ask how you achieve to tilted perspective in the map? I’m trying to render some buildings for a garden map project and only found a lattice deform of the mesh would work.

To get the tiles I used a python script, but what you probably want is that orthographic look. I used an orthographic camera put it to 0,0,2000. added an empty at 0,0,0 made the camera a child of it. rotated the empty 60° on X. And then I can move the empty along x,y plane and thats the point the camera is pointing to.
Now I’ve rendered allot of images each 256x256, each one tile of the map. However orthographic perspective at this camera angle will shorten dimensions along y-axis by half. You can go with that, as it looks correct. But I had to stretch it again to make it align with regular maps. So I made the aspect ratio in blender render settings 2:1 to get that “stretching”.

i tried this script but nothing happens when i export an osm xml file… im using blender 4.59. any step by step instuction how this works?

I know I’m dragging this thread up from the depths of the past, but can anyone get the OSM import working (or is there another OSM import that anyone else has worked on)?

Steps I took:

  1. Visit http://www.openstreetmap.org, zoom into location of interest
  2. Click Export, chose OpenStreetMap XML Data
  3. Downloaded the Blender OSM addon from here: https://github.com/der-On/OSM2Blender
  4. Open Blender, turn on addon (and Inset Polygon as this is required)
  5. Import data

Hooray! Empties created for the buildings… but that’s it. No polys or lines for the other features.

Is it possible the required addon Inset Polygons has moved on and broken compatibility with the OSM import?

Hi.

I’m sorry my addon was and is still purely experimental. Also I haven’t been updating the code to match the current 2.6x.
I might get back to it one day, however I first need an idea for a better user interface/interaction. This project also takes much time to develop, time I currently do not have.

Yep I quite understand, I have a number of projects under development and never enough time to complete them. I’ve been reading through the code; if I make any changes shall I zip them up and email them through to you? I want to get the SRTM contour data into Blender so that would be my first port of call. Which means finding out why Way’s aren’t coming in properly. Then after that, depending on time, maybe mock up some UI ideas. I’ll need a better understanding of the format and features first though.

Thanks for getting your import as far as you have :slight_smile: Much appreciated.

Oh and, did anything ever happen with the Blended Cities add-on? Or was that just an idea of where to take it next?

Hi again,

thank you for your understanding. I really love OSM+Blender and also that project but its a big thing. I also started another branch that tries to use objects as presets together with array modifiers but had to stop as it was veeery slow and not possible in blender.

If you want to fork my code simply create a fork at github and then a pull-request. That’s the best way.

Blended-Cities seems dead. It was maybe a little to much, what we wanted there.

To get SRTM Data into blender you simply need a geotiff + displacement modifier. Blender does understand this format. I’m already doing a project using geotiffs and it works very well. Do not convert the geotiff to grayscale images however as you’ll loose a lot of detail as you will be left with a maximum of 256 height levels. However to perfectly match OSM data onto a geotiff you’ll need some complex math as you need to handle the different geo projections. That is not a trivial task.

About the UI of OSM2Blender: the main problem is the shear complexity and freedom OSM datasets can have. There is no single way to rule them all, making it both flexible and easy to use. A wizard-like UI could work but only for some parts. I chose an approach that binds everything to materials. You define materials that get used to generate OSM geometry and you tag those materials. If a matching tag is found in the OSM dataset the material is used to generate geometry. That’s not very straight forward, but was my best guess. I had another experiment going on that uses a CSS-like text-file that described what OSM tags generate what kind of geometry. That is something for coders but could be better in the end. One could always stick a third party (web) interface on top of the CSS-files to hide the “coding” from the user but it stays a complex task.

Another thing is speed. In my test case I imported a very dens but small area (maybe 5km²) and it took about 10-30 minutes. At some point you’ll also come to the memory limits.

I know that getting such a tool to work together with SRTM data would be a killer! Even if the generated geomety is simple. It could create the possibility to bring an area to the third dimension in a very customizable way. This is interesting for the gaming, tourism and movie production business.

Ahh it all makes sense now (with materials). Now I’m getting somewhere. Using a CSS-like approach could work. I need to find out more about the types of features before thinking any more on that.

I’ve just been hacking at trunk with 2.66 (I’ll fork soon and make cleaner changes then) - I’d say the BMesh code has made some fairly major changes to the way OSM2Blender makes meshes. I’ve gone through and replaced mesh.faces with mesh.polygons as this seems to be the new thing (and might simplify a whole lot more code once I get a better understanding), but the current runtime error I’m getting is in Area.generate() on the line:
fill_vecs = geometry.tesselate_polygon([veclist])

It seems that your Geometry class doesn’t have a tesselate_polygon method?

As for SRTM, yep a displace would certainly do it, but I feel like the real contour data would be a more refined way of achieving it (I say as I sink back into my leather chair, cigar in one hand, whiskey in the other :slight_smile:

Wow. Cool that you got hooked up with it and contribute with code and ideas!

This makes me think If I could find some time to work on it again. Maybe bigstud80 when you pull your BMesh changes that make it work again I will try to move my CSS-experiment into the master branch. It currently resides in the presets branch.

batFinger: GDAL is strong, but GDAL is also complex as far as I remember. Maybe you could provide a detailed description of your workflow and your scripts to get to those results?

Btw.: I’ve created a GIMP script using the normalmap plugin that generates pretty nice normal maps based on this tutorial: http://cgtextures.com/content.php?action=tutorial&name=normalmap. I’ve also created a batch-script so one can convert multiple files at once. I’ve attached both scripts to my post.

Attachments

gimp_normalmap_scripts.zip (2.73 KB)