Tuesday, 20 January 2015

qgis - Enlarge a Polygon without changing its shape or position


I have a single polygon shapefile (EPSG: 3044) which I want to enlarge using QGIS 2.18.16. I tried to use the vector affine transformation plugin, but whenever I try to change the size of the polygon, the whole layer changes its position and shape. Is there a tool in QGIS where I can do this task or is it possible with the affine transformation plugin and I just cannot find the right values?


What I have: Some csv points and a country-border. The points do not have the correct positional accuracy. Therefore I want to enlarge the country-border so that all points fit into the poylgon.


What I get when I change the X and Y scale from 1,0 to 2,0: enter image description here



Answer



Both GRASS (as Erik Lohmann points out) and SAGA have tools that can accomplish this. I've accomplished this in the past using the tool SAGA > Vector General > Transform vector layer.




  1. In order to prevent your shape from "drifting", you'll need to derive the centroid first. Run Centroid, using input polygon_layer. Here's an example, with the centroid labelled using the expression x($geometry)||' '||y($geometry).


polygon w/ centroid




  1. Run Transform vector layer:



    • Shapes = polygon_layer

    • Scale Factor X/Y = the coefficient you want to enlarge by. In this example, I've specified a scale factor of 2 for both, meaning my output will be double the size of the input.

    • For parameters X and Y, input the centroid coordinates. These values serve as the anchor points from which your input will be scaled.





transform dialog


Output from the above shape, with the new shape's centroid visible:


transformed polygon


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...