As @MappaGnosis commented, you could write a script for this. Here's one called polygonbuffer
which takes three arguments: The output file name, the radius of your buffer, and the number of corners of the polygons.
Open a Python console in QGIS, paste the script and press enter to define the function, then call using something like polygonbuffer("polygons.shp",50,6)
to get hexagons with a radius of 50 map units:
import numpy as np
def polygonbuffer(outputFilename, bufferLength, polygonSides=6):
layer = qgis.utils.iface.activeLayer()
provider = layer.dataProvider()
fields = provider.fields()
writer = QgsVectorFileWriter(outputFilename, "CP1250", fields, QGis.WKBPolygon, provider.crs(), "ESRI Shapefile")
inFeat = QgsFeature()
outFeat = QgsFeature()
inGeom = QgsGeometry()
provider.select( provider.attributeIndexes() )
while provider.nextFeature(inFeat):
point = inFeat.geometry().asPoint()
inGeom = inFeat.geometry()
outFeat.setGeometry(QgsGeometry.fromPolygon(
[[QgsPoint(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.setAttributeMap( inFeat.attributeMap() )
writer.addFeature( outFeat )
del writer
newlayer = QgsVectorLayer(outputFilename, "Polygons", "ogr")
QgsMapLayerRegistry.instance().addMapLayer(newlayer)