I have an unreferenced point layer that is rectangular in shape. It is made out of rows of unequally spaced points, with spacing between the rows of either 1 or 3 meters.
I also have a multipolygon layer that corresponds with the mentioned point layer in size, but the multipolygon layer is georeferenced (the four corner coordinates are known). I also have a column that indicates where is the Zero/Start corner, with the following values: East, West, North, or South.
Is there a way in pyqgis to obtain the Zero/Start coordinate of the corner vertex from the polygon layer based on the value in the Zero/Start column? In the example shown, the value of the Zero/Start column is South. I would also like to know if there is a way to get the angle of rotation between two layers. My idea is to first rotate the point layer with the following code:
vector_layer_edit_utils = QgsVectorLayerEditUtils(lyr)
rotation_angle = 0 # angle that is needed
zero_start = QgsPointXY(0, 0) # start coordinate of the unreferenced point layer
lyr = QgsProject.instance().mapLayersByName("point_layer")[0]
feats = lyr.getFeatures()
lyr.startEditing()
for feat in feats:
geom = feat.geometry()
geom.rotate(rotation_angle, zero_start)
lyr.changeGeometry(feat.id(), geom)
lyr.commitChanges()
It's not clear to me what is the direction of the rotation, clockwise or counterclockwise. I would then translate the rotated layer to the coordinate obtained from the polygon vertex with the following code:
feats = lyr.getFeatures()
zero_coordinate = QgsPointXY(0, 0) # replace with the coordinate from the polygon layer
lyr.startEditing()
for feat in feats:
vector_layer_edit_utils.translateFeature(feat.id(), zero_coordinate.x(), zero_coordinate.y())
lyr.commitChanges()