3

I am testing different tree crown drawing options in QGIS. At the moment, I have found this option to be the most suitable for me.

Code:

convex_hull( 
            combine(buffer(make_point($x-("west"/2),$y),"west"/2),
            combine(buffer(make_point($x+("east"/2),$y),"east"/2),
            combine(buffer(make_point($x,$y+("north"/2)),"north"/2),
                    buffer(make_point($x,$y-("south"/2)),"south"/2))))
            )

Problem is that uneven crowns look very good, but even crowns look like rounded squares. I would like lines to curve a bit. Right now they are straight. I understand how generator draws them, but not enough to make it work like I would like. Info from the code author and how it works. Look for Solution 3. Rounded square tree crowns

2

Here is a very simple approach: Just add some randomness using rand() in your denominator:

with_variable('randmin',1,with_variable('randmax',3,
convex_hull( 
            combine(buffer(make_point($x-("west"/rand(@randmin,@randmax)),$y),"west"/rand(@randmin,@randmax)),
            combine(buffer(make_point($x+("east"/rand(@randmin,@randmax)),$y),"east"/rand(@randmin,@randmax)),
            combine(buffer(make_point($x,$y+("north"/rand(@randmin,@randmax))),"north"/rand(@randmin,@randmax)),
                    buffer(make_point($x,$y-("south"/rand(@randmin,@randmax))),"south"/rand(@randmin,@randmax)))))
            )
))

You may want to adjust the randmin (here 1) and randmax (here 3) argument in the first line, used as variables.

Here is an example result (I used 1 degree for west, east, north and south variable, it's in EPSG:4326 around the globe, thats why the northern ones are overly stretched):

enter image description here


I have also tried using an approach with point_on_surface() within a buffer of your convex hull outline as new vertex points of a polygon to make it more irregular. But seems like these point_on_surface() points aren't random. At least within my testings they got placed at the same location every time... Maybe I can get a result with some more testing. Update: got it working when including rand() here as well, but the result isnt really better than with this simple approach above, just takes a lot more computation...

2

Use smooth(geometry, n), where geometry is the expression you use to create your polygons and n is an arbitrary value: try different setting, what fits best your needs. n is optional, you could also use just smooth(geometry).

See the screenshot: The blue polygon is the smoothed version of the original (black line, here I used $geometry to smooth the current feature):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.