Hello,
I want to reduce the number of houses. I have a Startrule that generates these houses automatically. Now I want to reduce the number by 20 percent. An additional condition is that houses that are 20 meters or closer are eliminated.
Does anyone have any idea how to do this? I was thinking about minimumDistance, but I don't know exactly how to write the code. Or are there any other solutions?
Matthias BuehlerCheryl LauChris WilkinsThomas FuchsL R David Wasserman Michelle Mathias Elliot HartleyCheryl Lau
Burak
David Wasserman knows this one.
To clarify, you imagine the code to generate these houses will look like the following logic:
case probability a house is created && house is not within 20 meters of another house:
generate house
else:
no house (NIL)
I want to review the rule, but this is easier if the houses are generated on the same shape. For example, vehicles are allocated on the complete street rule using a recursive allocation method shared by Matthias B. Something similar is needed here, but if they are different parcels you will need minimumDistance for a fact (target selector would be "inter", I think). The code for that depends on the use of the label("thing") function. See the scatter example in the link above for a similar condition (red cylinders). My main concern is the distribution though. If they are independent shapes, controlling the order of generation and its implicit results on the final distribution of housing is not a clear cut thing. I imagine you might need to manually generate a few houses to set up a "init" results for start point distributions, similar to how various machine learning libraries give ways to set starting points for clustering resultings.
I am not an expert on minimumDistance, and it is a function I have read the documentation more than I have actually used. I like reading about it, have not had time to use it.
David
One method would be to scatter() some points, create 20m radius spheres at each point, remove spheres that occlude, and then further remove points using p() according to an attribute. This won't let you remove exactly 20% of the original number of points though.
@Range(min=0, max=1)
attr reduce = 0
const nPoints = 100
const minDist = 20
const cube_width = 10
Lot -->
scatter(surface, nPoints, uniform) { Point }
Point -->
s(2*minDist, 2*minDist, 2*minDist)
center(xz)
primitiveSphere
label("sphere")
TestSphere
TestSphere -->
case overlaps(intra, "sphere"):
NIL
else:
ReducePoints
ReducePoints -->
case p(reduce):
NIL
else:
s(cube_width, cube_width, cube_width)
center(xz)
primitiveCube
yes exactly that is the logic behind it. I have a single shapefile (see appendix) and this shapefile contains 262 shapes. All marked and the Startrule assigned, result in the different Buildings.
I forgot to mention that I only want to reduce the "Estate"-Buildings by 20 percent, all others should stay. And especially the buildings that are close to each other (20 meters) should be omitted.
thanks for your suggestion Cheryl. It doesn't have to be exactly the 20 percent but shouldn't be too far away from the 20 percent.
I'll try to apply the code to my rule tomorrow.
Understood. So there is a subcategory of building type that is reduced by some percentage?
Cheryl Lau's suggestions are good ones to use as a template. My only concern is the example you described might be a little more complicated if they are from independent shapes. There are not many examples for minimumDistance() using inter shape logic, but the general idea should be the same.
My principle concern is unlike the scatter operation, the distribution of independent shapes exists already. You might need to experiment on how to set up a starting distribution for buildings.
Exactly there are different types of buildings like residental, public, estate etc. And I just want to reduce a certain type of building.
I get the percentage reduction, only the condition with the 20 meters makes things difficult for me.
What exactly do you mean by the independent form? It's a single shapefile but you can also click and edit the 262 shapes in it one by one.
I have taken the code and inserted it into my rule (TestStartrule.cga) to see what it does. However, nothing happens. I may have to adapt it, but unfortunately I don't know how.
Draw a rectangle that is about 900m x 900m, and put the rule I posted on it, and you will see cubes scattered such that no cube is within 20m of another cube. You can move the slider for the attribute reduce in the Inspector to further reduce the number of cubes.