3

I have points that are not equal but the distance between them is so small that it can't be seen even at scale 200k:1. I calculated the distance between these points and add it as attribute. Now I want to find out where the points are so I select them in attribute table but can't see selection as the point is overlapped by another point.

Is there a way to fix this?

I know that i can set filter query on layer using the feature id. But I have way too many points to change the filter all the time. I am looking for different solution. Setting transparent style also does not help.

4
  • If you have calculated the distance, you could use a rule-based renderer based on this distance to display all points with a small distance in the map.
    – underdark
    Commented Dec 16, 2014 at 17:18
  • Sadly the distance is calculated to nearest point and points with small distances are paired -> if A is in short distance to B then B will also have small calculated distance to A as attribute, so both points will comply to any potential rule. Used distance matrix with N=1 to calculate distances.
    – gisit
    Commented Dec 16, 2014 at 18:16
  • Please clarify what you want to do, it's unclear to me what you want to select and do with the selection afterwards.
    – underdark
    Commented Dec 16, 2014 at 19:37
  • It's clear for me. I'm working on a workaround and will post it in some minutes... Commented Dec 16, 2014 at 19:48

1 Answer 1

3

I came across the same issue last week. Follow this work flow and you'll be able to see selected points, even if they share position with non-selected points:

  1. Load your point layer in QGIS and make sure it is in the first position of the ToC.
  2. Open the Python Console from Menu Plugins.
  3. Copy the next Python code in the Python console and press Enter (you might need to press Enter a couple of times until you get the "True" line).
from qgis.gui import QgsVertexMarker
from PyQt4.QtGui import QColor
from PyQt4 import QtCore

layer = iface.mapCanvas().layers()[0]
vertices = []

def showSelectedPoints():
    selected = layer.selectedFeatures()
    for f in selected: 
        vertex = QgsVertexMarker( iface.mapCanvas() )
        vertex.setCenter( f.geometry().asPoint() )
        vertex.setColor( QColor(255,0,0) )
        vertex.setIconType( 3 ) # ICON_BOX
        vertex.setIconSize( 12 )
        vertex.setPenWidth( 2 )
        vertices.append( vertex )

def removeSel():
    for v in vertices:
        iface.mapCanvas().scene().removeItem( v )
        del v

def updateSelection():
    removeSel()
    showSelectedPoints()

QtCore.QObject.connect( layer, QtCore.SIGNAL("selectionChanged()"), updateSelection)
  1. Open the attribute table and select some rows.

You should see a red box on every selected point. Every time you update the selection, the red boxes should appear/disappear accordingly.

If you don't like boxes or the color red, you could edit the methods setColor and setIconType on the code above and copy it again to the Python Console.

Please give it a try and tell me if something is unclear for you.

1
  • 1
    Great job! Working like a charm.
    – gisit
    Commented Dec 16, 2014 at 21:47

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.