4

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'
  • 2
    I don't see why this question was closed as off-topic. I think it was well-defined from the beginning. – Matthias Kuhn Nov 24 '17 at 12:51
0

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.

Your Answer

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

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