qgis – How to Edit Multiple Point Coordinates in QGIS

editingqgis

I'm using QGIS 3.20.2 and am wondering if it's possible to edit the coordinates of multiple points? I know I can edit individual points using the vertex editor. However I'm wanting to do edits along the lines of keeping the unique X coordinates for the points, but changing the Y coordinate to the same value for multiple points.

I have attempted to do this with the field calculator without success using the make_point expression. Is there a simple work around for this, or does it require editing in Excel and then importing the CSV again?

Best Answer

If you are ok with creating a new layer and want to move all points you can use "Geometry by expression":

make_point(x($geometry), 7572684)

enter image description here

Another option if you want to modify your layer in place is to use pyqgis. This will also allow you to move only selected points. Adjust the code, select the points you wan t to move and run:

lyr = QgsProject.instance().mapLayersByName('Random points')[0] #Change Random points to the name of your layer
newYCoordinate = 7573081.123 #Change
with edit(lyr):
    for selectedFeature in lyr.getSelectedFeatures(): #For each selected feature
        thePoint = selectedFeature.geometry().asPoint() #Fetch the point geometry
        newgeom = QgsPoint(thePoint.x(), newYCoordinate) #Create a new one using the old ones x coordinate, and your specified y coord
        selectedFeature.setGeometry(newgeom) #Set the geometry
        lyr.updateFeature(selectedFeature) #Update the feature

enter image description here

Related Question