OpenStreetmap Import

Hi,

recently I started a fun project: An OSM import for Blender 2.5x

The project is OpenSource and hosted at gitorious under https://gitorious.org/osm2blender

You can come and join the fun by cloning the repository and start coding or playing aroud with it.

The basic concept is as follows:

You create Materials and Groups within blender that you attach OSM “tags” to. The tags attached to materials will decide what kind of OSM features with multiple points (= multiple nodes forming a path or outline) will get the material. So for example if a material gets the “highway” tag all OSM features with the highway tag will get this material. The material also decides what kind of geometry will be generated. In that case it most likely will be a “trafficway”, which means a road. Groups will be instanciated where an OSM feature has only one point in space. This allows the addon to be very flexible, but the user must read about the OSM tags/features to know what tags should be attached.

Look in following posts for recent screenshots/renderings.

latest Download:

http://www.anzui.de/osm2blender/downloads/io_osm_27062011.zip

Installation:

Unzip the file and put the containing folder “io_osm” in your Blender/2.5x/scripts/addons/ folder. After that open up Blender and activate the addon “Import OSM” under File > User Preferences > Addons

Updates:

27.06.2011:

  • tag priority fix for building parts
  • also fixed missing assigment of tags with undefined value that have concuring tags of same name with some value

26.06.2011:

  • material priority fix
  • started debugging of material assignment

15.06. 2011:

  • sloped roofs are working thanks to howardt at #blenderpython chat
  • fixed wrong UVs for roads
  • added option to create a tag list in the internal “tags.txt” Text

Attachments


Ok one thing. This looks like a great project, but, why not make it easily downloadable. I know you programmer types know all about SVN and CVS and Repositories. But some of use here are just amateur artistic dabblers. A nice .zip or even .arc file would make it a LOT easier for us.

Allot of features is still waiting to be coded. Those are in order of realisation:

  • sloped roofs
  • junctions
  • groups attached/aligned to building facades/outlines (like entrances)
  • barriers http://wiki.openstreetmap.org/wiki/Map_Features#Barrier
  • scatterable objects/groups on flat areas (e.g. trees)
  • groups instanciated at each node/point of a path (e.g. power line towers)
  • groups instanciated between 2 nodes/points of a path and scaled along one axis to fit the distance (e.g. power line cables)
  • faster/smarter collision detection for z-sorting of roads and flat areas
  • level support (e.g. tunnels and bridges)
  • support for aeroways http://wiki.openstreetmap.org/wiki/Map_Features#Aeroway
  • additive import: import multiple osm xml files one after another, all covering only one part of a bigger area.

Sorry I forgot to post. The current version can be downloaded here: http://www.anzui.de/osm2blender/downloads/io_osm_10062011.zip

Unzip the file and put the containing folder “io_osm” in your Blender/2.5x/scripts/addons/ folder.

New version available for download. See initial post for details.

with textures (old)
huge orthographical view (recent)

I guess I don’t understand how to use this.
It does not show up under File/Import.
Even if it did, what would I do with it?
I really like the city shots, is this a city generator?

@atom : as far as I understand, this addon imports OSM files from http://www.openstreetmap.org/ , which can be described as an open google-map.
So it’s not a city generator, but rather a city “importator”.

@sam256 : Excellent idea, I will give it a try for sure.

Very nice. I had no idea that this script was this developed. I thought it was still a work in progress. I am going to download it right now.

Hi Atom,

to install it please follow the instructions above. The scripts folder is within your blender installation directory. You can also define a custom scripts folder in Blender under File > User Preferences > File > Scripts.

The usage of the importer is not that trivial, as it depends on tagging materials and groups. As that tagging is still buggy I have to do some fixing and will then upload a simple testfile, to get you going. It will contain a number of “tagged” materials and groups that will create buildings, some roads and things like benches, traffic signals and street lights.

Are you Der-on ? Your script is very good, keep it up… For anyone wanting to rendering a realistic specific location this addon is a god sent and I am sure it has many more applications too.

However even though your script like mine is far from finishes, its usable and its should be considered released. So it must go to the release forum and not here.

I got a little further.
I exported a OSM file from the website above.
I did install it in the correct location, but you still have to activate it in the User Preferences AddOns panel.

When I run it, all I get is a bunch of empties at world origin.
What do I do now to get roads and buildings?

This question totally had to come, so I will try to explain how to create simple buildings.
All those empties are Objects imported from OSM. When you select one and go to the Object tab, you can see all OSM tags it has and other info in the “OSM” panel.

  1. Create a dummy object (cube or whatever) in one of the last layers, or even in another scene.

  2. Assign a Material to that dummy object, call it “building_facade”

  3. Scroll down to the “OSM” panel in the Material settings

  4. Set the “Base type” to “building”

  5. Set “Part” to “facade”

  6. Assign a texture to the material with some nice facades on it.

  7. Go back to Material settings and change “Number of levels in texture” to the number of levels your facade texture has.

  8. Also change “level height” to how high in meters you think one level in your texture is.

  9. Change “Default number of levels” to at least the number of levels in texture, to make buildings at least as height as your texture is.

  10. Now hit “Add tag”

  11. A new Tag will appear below, set its Name to “building” and keep the rest of the options as is.

  12. Now create a second Material within the dummy object and call it “building_flat_roof”.

  13. Base type is “building” again, and “Part” now “flat roof”.

  14. Add a texture to that material.

  15. Add a tag again, Name=“building”

This will now create buildings from all Objects that have the “building” tag with any value.

Try the same for roads, by creating a material with the “Base type” “trafficway” and by adding a tag with the name “highway” to it.

To understand tagging you need to understand how OSM uses tags and what kind of tags and combinations of tags represent what kind of physical object.

Next example is how to traffic signals:

  1. Model a traffic signal (it can be made up of multiple objects) and add all objects to a group called “traffic_signal”.
  2. Select one of the traffic signal objects, go to the object tab and scroll down to the OSM panel.
  3. Hit “Add tag”
  4. Set the name of the tag to “highway” and the value to “traffic_signals”

Now it will place an instance of this group in each OSM object that has the “highway” tag with a value of “traffic_signals”.

Tip: when importing you can check “Create tag list” on the left in the file browser to get an internal Text called “tags.txt” which shows all tags used and how often they are used and if they are used on WAYs (=outlines) or NODEs (=Points in space)

Additionally I’ve now uploaded a map_template containing some groups and materials. Download it here.

Thanks for the information.

Here is some feedback.

There is a minor bug in your script when activating it. Open up user preferences and activate the script. On my system there is a short delay so I thought I had not clicked the check box. So I clicked again which actually turned it off. When I tried to re-activate the script it did not work. Something about already being registered error.

I followed the steps but you lost me here.

This will now create buildings from all Objects that have the “building” tag with any value.

Nothing was actually created?

I realize this is a complex script but it would be nice if the script had a “Wizard” button somewhere to automate some of those manual tasks you describe. For instance, just make default cubes and materials for everything. Then I could just browse to images, right?

I am no stranger to complex scripts, but I still can not get anything out of this script. I am not saying it does not work, however. I want the instant joy button, please…

<------ Its called “Documentation” Even after 30 + years of using computers of one type or another it still amazed me how people that have a talent for programming just assume that everyone can understand the programs that they write without the need to explain it. I mean I still just shake my heard. That was not a slight against you Sam256 I see it all the time from a LOT of programmers.

Hi SHABA1,

I actually studied something that deals with technical documentation and know it’s value and how it should be done and my diploma was specialized in GUIs for Web-Applications. However in this case I simply did not had the time to write docs for something that is not finished at all and subject to change. Another thing why I didn’t wrote docs in the first place, is that as the developer I loose the sight an end-user has and now I write docs on demand and as I find time based on the problems users face. I haven’t opened this thread under released script, because this script at the moment is more of a proof of concept and just a hobby project.

I absolutely understand that one cannot get the concept behind this addon right after installing it. But I can’t understand why people “yell” for an instant-joy button if they face something complex that obviously is in early development. I see this kind of behaviour all the time on the other side (at the end-user side), just like I see what you said, missing docs, but on (almost) finished software.

Now OSM is a complex thing and I decided to create a flexible importer instead of an uber-easy-one-button-does-it-all one. It has the downside of forcing the user to study the OSM tags. Instead I though I might provide some template files, as I did above, to get you started. I think the problem Atom faced is actually a bug. I’ve now uploaded a more recent version, that should work. (See first post for download)

Please try my template file first. Look into the Scene “background” there are objects in the last layers you should investigate. Actually I won’t bring you a wizard (yet), instead I give you template files that should get you going.

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

I will have to agree with SAM in this if a product is not finished or at least not near completion, there should not be any documentation. Why ? Because if you are annoyed now that there is no documentation imagine how much annoyed you would be struggling to do something following the documentation only to find out after too much pain that that feature changed and so documentation is invalid.

That is why you rarely see programmers do documentation of their programs, because its the final thing a programmer does. A unfinished script are for ones that can read and understand the code and even offer insight on what it works and what doesnt.

And of course even coder cannot easily understand the programm with no documentation. So docs are as important to users as they are to coders. However docs take time to make and you will have to be patient. When I first tried Sam script we walked me through to it, so you are not the only one, and I know how to understand python.

Thanks kilon for your support. :slight_smile:

I’ve uploaded an update that fixes an important bug with building materials.