I'm currently trying to create a series of subplots within a larger plot, but outside of a nesting smaller plot, and am having trouble with it. This is the code I'm working from. I've also added a picture of what I'm trying to get at the bottom.
Learning QGIS=group
input_layer=vector
size=number 15
subplotsize=number 2
subplots=number 4
squares=output vector
minisquares=output vector
from qgis.core import *
from processing.tools.vector import VectorWriter
import random
# get the input layer and its fields
my_layer = processing.getObject(input_layer)
fields = my_layer.dataProvider().fields()
#get the input layer and its fields
my_layer2 = processing.getObject(input_layer)
fields2 = my_layer2.dataProvider().fields()
# create the output vector writer with the same fields
writer = VectorWriter(squares, None, fields, QGis.WKBPolygon, my_layer.crs())
writer2 = VectorWriter(minisquares, None, fields2, QGis. WKBPolygon, my_layer2.crs())
# create output features
feat = QgsFeature()
feat2 = QgsFeature()
sx=subplots
sps=subplotsize/2
for input_feature in my_layer.getFeatures():
# copy attributes from the input point feature
attributes = input_feature.attributes()
feat.setAttributes(attributes)
# create square polygons
point = input_feature.geometry().asPoint()
xmin = point.x() - size/2
ymin = point.y() - size/2
for tx in range(0, sx):
px=random.uniform(1, 10) - 5 + point.x()
py=random.uniform(1, 10) - 5 + point.y()
print px, py
square = QgsRectangle(px-sps, py-sps, px+sps, py+sps)
feat2.setGeometry(QgsGeometry.fromRect(square))
writer2.addFeature(feat2)
square = QgsRectangle(xmin,ymin,xmin+size,ymin+size)
feat.setGeometry(QgsGeometry.fromRect(square))
writer.addFeature(feat)
del writer
I know this is probably a basic question, but I'm new to coding and all I've managed to do is move around the coordinates of the subplots.

