6

I have used the Geometry Generator in QGIS to successfully create a polygon around a point that represents the canopy of a tree based on the cardinal direction recordings.

What I cannot figure out or find any information on is how to make this work for a multi-point feature. The code below works on a single-point feature or the first part of a multi-point feature geometry but I want it to create the same 'canopy' polygon over each point in the multi-point feature.

collect_geometries( 
  geometries_to_array(
    convex_hull(
      combine(
          buffer(
            make_point($x-("TreeInfo_Canopy W"/2), $y),
            "TreeInfo_Canopy W"/2),
        combine(
          buffer(
            make_point($x+("TreeInfo_Canopy E"/2), $y),
            "TreeInfo_Canopy E"/2),
          combine(
            buffer(
              make_point($x, $y+("TreeInfo_Canopy N"/2)),
              "TreeInfo_Canopy N"/2),
            buffer(
              make_point($x, $y-("TreeInfo_Canopy S"/2)),
              "TreeInfo_Canopy S"/2)
          )
        )
      )
    )
  )
)

2 Answers 2

10

You need to make an array from MultiPoint geometry, but you try to make it from the Convex Hull (which is already one element, not multiple).

collect_geometries(
  array_foreach(
    geometries_to_array($geometry), -- make array from multipoint
    -- make convex_hull for each point
    convex_hull(
      combine(  -- combine(combined, combined)
        combine(  -- combine(buffer, buffer)
          buffer(
            make_point(
              x(@element)-("TreeInfo_Canopy W"/2),
              y(@element)),
            "TreeInfo_Canopy W"/2
          ),
          buffer(
            make_point(
              x(@element)+("TreeInfo_Canopy E"/2), 
              y(@element)),
            "TreeInfo_Canopy E"/2
          )
        ),
        combine(  -- combine(buffer, buffer)
          buffer(
            make_point(
              x(@element), 
              y(@element)+("TreeInfo_Canopy N"/2)),
            "TreeInfo_Canopy N"/2
          ),
          buffer(
            make_point(
              x(@element), 
              y(@element)-("TreeInfo_Canopy S"/2)),
            "TreeInfo_Canopy S"/2
          )
        )
      )
    )
  )
)

enter image description here

Move convex_hull( line to top line if you need the convex hull for the buffers of all points in the multipoint.

convex_hull(
  collect_geometries(
    ...
    ...

enter image description here

6
collect_geometries( 
array_foreach(geometries_to_array( $geometry ) ,
collect_geometries( 
  geometries_to_array(
    convex_hull(
      combine(
          buffer(
            make_point(x(@element)-("canopy_w"/2), y(@element)),
            "canopy_w"/2),
        combine(
          buffer(
            make_point(x(@element)+("canopy_e"/2), y(@element)),
            "canopy_e"/2),
          combine(
            buffer(
              make_point(x(@element), y(@element)+("canpoy_n"/2)),
              "canpoy_n"/2),
            buffer(
              make_point(x(@element), y(@element)-("canopy_s"/2)),
              "canopy_s"/2)
          )
        )
      )
    )
  )
)))

enter image description here

1
  • 1
    I would be thankful to hear some explanations from you ^_^
    – Taras
    Mar 7 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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