0

How to align points with QGIS like in CorelDraw. Align left, top etc?

I have some points and want to align them to top in one line. I can change the Y coordinate of every point but it will take a lot of time.

Or is there a way to change the Y coordinate for selected points?

Any plugin?

enter image description here

1
  • Don't forget to take the Tour where you will see that there should be only one question asked per question under our focussed Q&A format. Also, you originally asked this at Geographic Information Systems Meta so I migrated it here to the Main site.
    – PolyGeo
    Sep 28, 2017 at 9:24

1 Answer 1

1

If you're confortable with python and PyQGIS you can do this with this code snippet :

#get the layer
layer = iface.activeLayer()
layer.startEditing()

#get the y value of selected Point
y_list = []
for elem in layer.selectedFeatures():
    y_list.append(elem.geometry().asPoint().y())

#change the geometry of selected Point
for elem in layer.selectedFeatures():
    geom = QgsGeometry().fromPoint(QgsPoint(elem.geometry().asPoint().x(), max(y_list))) #keep X value and change y to the max y previously find
    layer.changeGeometry(elem.id(), geom)

You just need to Copy/paste this code in the editor of the python console then select your layer and select all the point you need to align, then run.

The code will find the maximum y value of the selected point and change the y value of others point accordingly.

Be careful that you have Point and not MultiPoint and that your CRS is coherent with using the max y value.

Before enter image description here

After enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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