6

I am trying to implement QGIS spatial query functionality in my plugin. I want to eliminate spatial operators which are not suitable for certain geometries. For eg. when I select layer with point geometry only certain(crosses,intersects, is disjoint,touches, Within) spatial operators are given by QGIS. Want to determine how to get to this result.

Got the layer geometry types using:

    layer = iface1.activeLayer()

    if layer.wkbType()==QGis.WKBPoint:
        print 'Layer is a point layer'

    if layer.wkbType()==QGis.WKBLineString:
        print 'Layer is a line layer'

    if layer.wkbType()==QGis.WKBPolygon:
        print 'Layer is a polygon layer'

    if layer.wkbType()==QGis.WKBMultiPolygon:
        print 'Layer is a multi-polygon layer'

    if layer.wkbType()==100:
        print 'Layer is a data-only layer'
1
  • 3
    I don't see why this question was closed as off-topic. I think it was well-defined from the beginning. Commented Nov 24, 2017 at 12:51

1 Answer 1

1

PyGIS is built over GEOS. In GEOS there is an upper level geometry with all spatial predicates methods, therefore every geometry type will be able to access all spatial predicates methods.

The only way I see for you to do that is to create your own PyQGIS method to make a list of available spatial predicates between two geometries. You need to remember that the list of spatial predicates depends on the type of the both geometries under analysis. For instance, between point and point there is no use for the within predicate, but between point and polygon it makes sense to use within.

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