I need to find distance in eastward direction from each point to the closest polygon edge:
I can find shortest distance in any direction with:
pointlayer = QgsProject.instance().mapLayersByName('points_inter_squares')[0]
points = [[f.geometry(),f['Ruta_100km']] for f in pointlayer.getFeatures()]
squarelayer = QgsProject.instance().mapLayersByName('squares')[0]
squares = [[f.geometry(),f['Ruta_100km']] for f in squarelayer.getFeatures()]
for point in points:
print(min([QgsGeometry.distance(point[0],square[0]) for square in squares if point[1]!=square[1]]))
>>12639.380321901293
>>3320.150455611874
>>6650.862023710273
>>2452.079442886869
'Ruta_100km' is the Squares IDs, so I measure distance to all Squares but the one intersecting the Points.
Is there a method where I can specify direction when measuring distance?