In QGIS 2.18 in my current point-layer I have related coordinates, which I would like to pop up when clicking on a point in the point layer. I try to use QGIS "Action" for this.

Simplified example of my point-Layer:

ID_____ | X_____ | Y_____ | Xrel__ | Yrel__


A______ | 1.0___ | 1.0___ | 1.2___ | 1.3___  
A______ | 1.0___ | 1.0___ | 1.5___ | 1.0___  
A______ | 1.0___ | 1.0___ | 1.0___ | 1.1___  
B______ | 2.0___ | 2.0___ | 2.2___ | 1.9___  

So when clicking on point A (or nearby coordinate of point A) I would like to highlight the coordinates of Xrel and Yrel corresponding to A. Is there a way to do this using the Generic or Python action type?

Preferably when selecting another point or deselecting, the highlighted coordinates disappear.

I made a sample script that follows the steps I want to do. It is not in pygis style, but more a guideline of what I want to achieve:

# here some code to load all necessary python gis modules

# create a small buffer around the point where the user clicked
coordinateBuffer = buffer(clickedPointOnMap,0.0001)

# find all features within that buffer in the feature class (point layer)
pointsInBuffer = intersect(pointLayer,coordinateBuffer)

# statement to make sure to remove previous created points
    if isempty(pointsInBuffer)
        if isnotempty(pointsOnMap)
    else break
    if isnotempty(pointsOnMap)
        # extract coordinates in the attribute table of the point layer
        toHighlight = pointsInBuffer[:, (Xrel,Yrel)]

        # create a point and set layout of the toHighlight points layer
        pointsOnMap = make(toHighlight)

Action panel in QGIS

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.