Geographic Information Systems Asked on November 23, 2021
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'
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.
Answered by lcoandrade on November 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP