Use the OSM Attributes

739
11
Jump to solution
02-26-2013 03:12 AM
DanielS
New Contributor
Hey everyone,

Is it possible to use the imported OSM Attributes?

I make a Rule with the Attribute height (attr height = rand(10,50)) the building is shown in this height(s). Everything is fine.
But I like to use the attributes from the OSM-data if available. Because of this the attribute have the same name like the Attribute in the ???Object Attributes???.
I tried to connect it with the ???Attribute Connection Editor??? but the selection for ???Object attribute??? is grey, cannot be selected???
[ATTACH=CONFIG]22169[/ATTACH]

What can I do?

Thanks a lot
0 Kudos
1 Solution

Accepted Solutions
MatthiasBuehler1
Frequent Contributor II
hi.

You don't want to have those values to be strings. You NEED floats to be floats for e.g. the extrude.

So you'd use something like ..

attr height = ""  heightFunction =     case height == "" : rand(30, 50)     else : float(height)  Lot -->     extrude(heightFunction)

or similar.

View solution in original post

0 Kudos
11 Replies
MatthiasBuehler1
Frequent Contributor II
Hi ..


It seems there is no attribute with the specific name 'height'.. Can that be ?

Check the object attributes of the shapes.

Note also that the data type may be wrong. E.g. the height value may be stored as string instead of a float value.

Check my tutorial videos 4 and 5 here concerning more OSM inputs :
http://forums.arcgis.com/threads/64843-CityEngine-Collection-RESOURCES-FAQ-HELP


Let me know if you need more info.

Cheers !

Matt
0 Kudos
DanielS
New Contributor
Hey,

thanks for your answer.

As written is the name of the attribute in the rule and the name of the object attribute the same (this is the only reason why I named it �??height�?� :)).
[ATTACH=CONFIG]22183[/ATTACH]

As I imported the OSM-File I selected only the buildings so the data type should be correct?! What can I do?

Another question: What about object attributes like roof:shape?! I think �??:�?� doesn´t work as attribute name?!

Thanks for the help again
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Ha, ok, gotcha. :)


Can you post the osm file ? I could try and have a look myself.

Let me know ..

Matt
0 Kudos
DanielS
New Contributor
Hey,

here is the file, hope it works:

[ATTACH=CONFIG]22207[/ATTACH]

I tried it with the building in the north (MVV, has the attribute height in it).

I hope you find my mistake.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Seems indeed that the height is stored as a string. In this case, use :

attr height = "" # initialize as string

Lot -->
 extrude(float(height))


Ok ?
0 Kudos
DanielS
New Contributor
Hey,

thank you very much, it works.
Now I can select the object attribute in the attribute connection editor.

But the buildings without the attribute height (from the OSM data) take the height from the rule as object attribute. Hope it is clear what I mean.
[ATTACH=CONFIG]22248[/ATTACH]

And how can I use random heights for the buildings now? What about the attribute roof:shape?! How can I use it?

I know, a lot of questions, hope you (or someone else) can help me again.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Hi !

If you assign a rule to a shape, CE checks if there is are object attributes for each initialized attr in the rule. If so, we assume that you want to use that value since you have imported that data.

Initializing an attr can be done with

attr myAttr = 0, with a value of 0.
or
attr myAttr = rand(20,50), a random value.

Check that for the cases where you HAVE an object attr called 'height', CE connected the 'ATTRIBUTE SOURCE' to the object attr. So it says in the Inspector :
height : 10.3 (Object). The thing in the brackets is where the source of that attr value is.

If there is NO object attr of that name you see there's written (Rule), because here is no imported attribute data, so the second guess is that you want to use the rule's initialized value.

Using the Connection Editor, you can choose that source of course.

So the answer is above. Just use a function or a random value or a mapped value. Up to you.
Did you check the tutorial videos ?
http://forums.arcgis.com/threads/64843-CityEngine-Collection-RESOURCES-FAQ-HELP



Ah, sorry. Forgot to check the aaa:bbb case. Will do that now.

M.
0 Kudos
MatthiasBuehler1
Frequent Contributor II
hi ..

CGA does not allow attr names with ':' or such characters.

You'd need to preprocess your OSM data first (in CityEngine) by using Python to replace all those characters to something more useful like '_', which is supported in CGA.

This can cause name clashes which you need to deal with.

Do you have some Python scripting / other scripting experience ?

M.
0 Kudos
DanielS
New Contributor
Hey,

I tried it again, it works without problems, my thinking was wrong, I thought I have to select the attributes in editor. Sorry for the confusion.

How to define a attribute is clear, I also have checked the tutorials :) they helped me a lot, not only with this problem. The problem is that I cannot make a string "rand (20,50)"...

The answer for the ":" problem is enough, thank you, I don´t have much Python scripting experience, but that´s my problem :)
I only want to know how it works, now I can try.

Thanks again for your time.
0 Kudos