1

I am working with a point layer which has a set of field where are stored some information about a rectangular geometry. This information is width, length and rotation of the shortest side of the rectangle. Given that the point is always placed on the centroid of the rectangle, is it possible for QGIS to automatically draw a polygon on another layer every time one point is inserted? Is there a way to implement this function in a QField project?

1
  • 1
    If you need indeed a new layer, a virtual layer would be a solution. For visualization only, Geometry Generator would be good, as well.
    – Babel
    Commented Jan 3 at 17:47

1 Answer 1

2

As Babel commented, either geometry generator (for visualisation only) or a virtual layer. If you are using a format such as GeoPackage or PostGIS that suports triggers, that would work as well.

The virtual layer SQL would look something like the below, replacing myWidth, myLength, myRotation, and myLayer with your attribute and layer names.

select
    rotate(
        geom_from_wkt ('POLYGON(('||
        x(geometry) - "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2    ||','||
        x(geometry) - "myWidth" / 2 ||' '|| y(geometry) + "myLength" / 2    ||','||
        x(geometry) + "myWidth" / 2 ||' '|| y(geometry) + "myLength" / 2    ||','||
        x(geometry) + "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2    ||','||
        x(geometry) - "myWidth" / 2 ||' '|| y(geometry) - "myLength" / 2    ||'))
        '),
        "myRotation") as geometry
from myLayer

Your Answer

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

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