Is there anyway to fill an irregular polygon with regular points but to also offset this regular point pattern with a defined angle offset from north? I make reference to an older answered post regarding the filling of polygons

Filling polygons with points or polygons

  • is this for cartographic reasons (to do stippling) or do you actually need the points e.g. to do sampling?
    – Steven Kay
    Jun 1 '17 at 17:36
  • The points are representative of a wind turbine points within an array. so i would like to adjust the angle of the points to a defined value or another layer attribute value
    – user95443
    Jun 2 '17 at 9:13
  • @user95443 any news about the solution?
    – mgri
    Jul 2 '17 at 19:10

You may run this code (adapted from this post I wrote some time ago) from the Python Console for controlling the spacing of your points and the inset from the North:

from qgis.core import *

# Set the spacing
spacing = 10
# Set the inset
inset_x = 5
inset_y = 5

# Get the Coordinate Reference System and the extent from the loaded layer
layer = iface.activeLayer() # load the layer as you want
crs = layer.crs().toWkt()

# Create a new vector point layer
points_layer = QgsVectorLayer('Point?crs=' + crs, 'grid', "memory")
prov = points_layer.dataProvider()

# Create the coordinates of the points in the grid
points = []

for ft in layer.getFeatures():
    feat_geom = ft.geometry()
    # Set the extent of the new layer
    xmin = ext.xMinimum() + inset_x
    xmax = ext.xMaximum()
    ymin = ext.yMinimum()
    ymax = ext.yMaximum() - inset_y
    y = ymax
    while y >= ymin:
        x = xmin
        while x <= xmax:
            geom = QgsGeometry().fromPoint(QgsPoint(x, y))
            feat = QgsFeature()
            point = QgsPoint(x,y)
            if feat_geom.contains(feat.geometry()):
            x += spacing
        y = y - spacing


# Add the layer to the map

For example, using a high value for the insets (inset_x = 50 and inset_y = 30), I get this result:

enter image description here

I hope having understood what you want. If you defined an angle instead of two insets, it is easy translating it as two length values (I can also edit the answer if you add more specific information about the problem).

  • I have the same problem as in creating a grid that is oriented at a certain angle from the north. I have added a rotation angle but end up with just one rotate line of points. Should I create a new post or keep it here, since the original question mentions a rotation?
    – Techie_Gus
    Nov 7 '19 at 7:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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