6

I have more than 1000 polygons, but they do not have the correct size and location. I have a table with the correct coordinates (centroid) "x, y" and different scale factor for each polygon.

How can I automatically resize them and move them all to their correct location? In QGIS I used use the plugin "Transformation Afine" for individually polygons or scaling tool in advanced edit (ArcMap). My shapefile use EPSG:5367 (local system CRTM05).

Fields

The batch processing does not recognize fields, only values

The batch processing does not recognize fields, only values.

5

1 Answer 1

6

In QGIS you can create a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer.... with a SpatiaLite expression to perform the transformation that you need:

SELECT
    ShiftCoords(
        ScaleCoords(
            ShiftCoords(
                a.geometry,
                -X(Centroid(a.geometry)),
                -Y(Centroid(a.geometry))
                ),
            a.factor
            ),
        a.x,
        a.y
        ) AS geometry,
    a.id AS id 
FROM
    "scale" AS a

With this query, we are:

  • Translating each polygon to the origin of coordinates by subtracting the coordinates of its centroid from all its points: ShiftCoords(a.geometry,- X(Centroid(a.geometry)),-Y(Centroid(a.geometry))).

  • Scaling each translated polygon by the factor value stored in the "factor" field: ScaleCoords(..., a.factor).

  • Translating again each scaled polygon to the correct values of the "x" and "y" fields: ShiftCoords( ..., a.x, a.y).

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.