Is there a way of labeling the number of points with the same coordinates?

Nice question! PyQGIS to the rescue!

Follow these steps to get a new field (in your original layer) called label with the number of points that lie in the same location:

  1. Active (select) your layer in the QGIS ToC.
  2. Run this code snippet in the QGIS Python console:

    from PyQt4.QtCore import QVariant
    
    lyr = iface.activeLayer()
    
    # Create New Field
    lyr.dataProvider().addAttributes([QgsField("label", QVariant.Int)])
    lyr.updateFields()
    fIdx = lyr.fieldNameIndex( 'label' )
    
    # Create Spatial Index
    idx = QgsSpatialIndex()
    for f in lyr.getFeatures():
      idx.insertFeature(f)
    
    # Use the Spatial Index
    attrFeatMap = {}
    for f in lyr.getFeatures():
      if not f.id() in attrFeatMap:
        res = idx.intersects( f.geometry().boundingBox() )
        for id in res:
           attrFeatMap[id] = { fIdx : len(res) }
    
    # Write calculated count to the label field
    lyr.dataProvider().changeAttributeValues( attrFeatMap )
    
  3. Open layer properties and configure labels selecting the label field we've just populated.

  4. This is the result:

    enter image description here


EDIT:

As you would also like to filter by an attribute, you can define an expression in the beginning of the code (for example, after the Create New Field block):

expr = QgsExpression( '"string"=\'{}\''.format("abc") )

and replace the two calls to lyr.getFeatures() by:

lyr.getFeatures( QgsFeatureRequest( expr ) )

That way you'll only get the count of the points with the same coordinates that fulfill the string=abc condition.


If I understand, you want aggregate a layer by location. You will need SQL for that, so create a virtual layer (Qgis >= 2.14) with a query like :

SELECT geometry, count(*) AS count FROM your_layer GROUP BY geometry

You can now use the "count" field of the virtual layer as label.

For adding the filter by the text field :

SELECT 
  geometry, 
  count(*) AS count_total,
  count(CASE WHEN filter_field = "abc" THEN 1 ELSE NULL END) as count_filter
FROM your_layer GROUP BY geometry

Adapt words to your layer : your_layer, filter_field and "abc".


you can use Rule-based labeling

shapefile point before the rule fig_1

all the points they label.

fig_2

after the rule:

fig_3

using rules you can specify which labels to show, even using conditional statements