0

I've noted at Polygon in specific size that the QAD plugin can be used to create specifically sized polygons, however it is not compatible with QGIS versions newer than 2.9.

Any suggestions for a workaround?

I'm presently incrementally resizing my polygons then using the field calculator to approximate their sizes: however, since there are many polygons and they have to be very specific sizes, this method is prohibitively time consuming.

  • Workaround discovered, I simply downloaded 2.18 so I can use it's functionalities until 3.x can accept plugins such as QAD. – Eddie Arni Jan 11 at 20:29
1

I think xunilk's answer is the best overall solution, but here a couple of suggestions that could improve your current workflow.

You can use the identify tool to get polygon area. Just select the Identify tool, click on the polygon and expand the "derived" section of identify results. You can even choose the option to "expand new results by default" so you don't have to open the derived section each time. (You can change the area units in Project menu > Properties > General > Measurements.)

enter image description here

The "Split Features on Steroids" plugin allows you to

Split one or more polygon/multipolygon features showing the resulting areas on each side of the cutting line. Adjust the vertices of the cutting line before splitting.

So you could create a too-large polygon, use this plugin to split off a polygon exactly the right size, then delete the unwanted portion.

Note: QGIS plugins are created by outside developers, much like third-party apps for your phone. Each plugin must be updated to maintain compatibility with QGIS. If the plugin developer has abandoned it, then it may never be updated. You can watch the github page for the QAD plugin for updates. Also keep checking the plugin manager for new plugins, in case someone creates a new plugin that does what you want.

  • I think the "Split Features on Steroids" is probably the best answer. I'm not looking to create a bunch of regular shapes, these will be all irregularly shaped polygons. – Eddie Arni Jan 16 at 22:14
1

Despite your discovered workaround, following PyQGIS code can also be used to create different sized polygons with sligth modifications. This code specifically produces regular pentagons (formula for pentagon area can be obtained from here) by using a point layer with multi features.

import numpy as np

area = 2377641.2907378837 #considering a regular pentagon

#bufferLength obtained from area formula of regular pentagon
bufferLength = np.sqrt((2./5.)*(area/np.sin(72.*np.pi/180.)))

print (bufferLength) #value must be 1000 meters if area is equal to 2377641.2907378837 square meters

polygonSides = 5  #considering a regular pentagon

layer = qgis.utils.iface.activeLayer()

points = [ feat.geometry().asPoint() for feat in layer.getFeatures() ]

epsg = layer.crs().postgisSrid()

uri = "Polygon?crs=epsg:" + str(epsg) + "&field=id:integer""&index=yes"

mem_layer = QgsVectorLayer(uri,
                           'pentagons',
                           'memory')

prov = mem_layer.dataProvider()

for i, point in enumerate(points):
    outFeat = QgsFeature()

    outFeat.setGeometry(QgsGeometry.fromMultiPolygonXY([[[ QgsPointXY(point[0] + np.sin(angle)*bufferLength, point[1] + np.cos(angle)*bufferLength)
                        for angle in np.linspace(0, 2*np.pi, polygonSides, endpoint = False) ]]]))

    outFeat.setAttributes([i])
    prov.addFeatures([outFeat])

QgsProject.instance().addMapLayer(mem_layer)

Point layer used for testing above code can be observed at following image:

enter image description here

After running the code, result is observed below:

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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