Closed ju4e closed 7 years ago
Hello, I do this in one of our plugins, it's works:
from mask import aeag_mask
mapcrs = iface.canvas.mapSettings().destinationCrs()
geom = QgsGeometry(...)
aeag_mask.do(mapcrs, [geom], "layerName")
Can you tell me more about the plugin or QGis version ?
Thanks
Hello, Thank you for your reply. Here are my system specifications :
from mask import aeag_mask mymapcrs=2154 masklayerName='mask_layer' geom=QgsGeometry.fromWkt("Polygon(((468157.07000000000698492 6360943.53000000026077032, 468136.86999999999534339 6360937.42999999970197678, 468134.17999999999301508 6360946.20000000018626451, 468119.84999999997671694 6360953.19000000040978193, 468128.82000000000698492 6360970.79999999981373549, 468147.40999999997438863 6360975.92999999970197678, 468157.07000000000698492 6360943.53000000026077032)))") aeag_mask.do(mymapcrs, geom, masklayerName)
the error described in my first post always appears..
Any idea?
Thanks.
Try this :
from mask import aeag_mask
# build a QgsCoordinateReferenceSystem object
mymapcrs = QgsCoordinateReferenceSystem(2154)
# two parenthesis for a simple polygon
geom=QgsGeometry.fromWkt("Polygon(( 468157 6360943, 468136 6360937, 468134 6360946, 468119 6360953, 468128 6360970, 468147 6360975, 468157 6360943 ))")
# and then, pass a array of geom
aeag_mask.do(mymapcrs, [geom], masklayerName)
Casteljaloux, ce n'est pas très loin d'ici !
Thank you, it's working! It seems that defining the pcrs by its only epsg code is not enough..
Et oui, Casteljaloux est aussi sur le territoire d'intervention de l'aeag! ;)
Perfect, I will try to enrich the doc...
hello, I'm tying to generate a mask using aeag_mask.do function in another plugin. When i call this fuction, using geometry of selected feature in a layer, an error occur : "Traceback (most recent call last): File "", line 3, in
File "C:/Users/Julien/.qgis2/python/plugins\mask\aeag_mask.py", line 61, in do
this.layer = this.apply_mask_parameters(this.layer, this.parameters, crs, poly, name, keep_layer = False )
File "C:/Users/Julien/.qgis2/python/plugins\mask\aeag_mask.py", line 459, in apply_mask_parameters
layer = QgsVectorLayer("MultiPolygon?crs=%s" % dest_crs.authid(), mask_name, "memory")
AttributeError: 'int' object has no attribute 'authid'"
I have correctly defined do function's parameters (layer's crs, feature's geometry..) so i don't understand this error. Could you enlighten me on that? thanks Julien