Hi Marian,
I suppose the QGIS Clip algorithm does not work on "memory"-Layers, i.e.
Layers that are not written to disk. You can either try to save your
layer as a shapefile and then run the clipping algorithm, or iterate
over the geometries and use the QgsGeometry.Intersection(QgsGeometry)
function
(https://qgis.org/api/classQgsGeometry.html#a6ca0f918c7c67aff8ac9e0094707c99e).
This could be something like this (not tested, just off the top of my head):
clipPoly = clipLayer.getFeatures()[0].geometry() # get the first feature
(assumes only one polygon)
for input_feat in inputLayer.getFeatures():
input_geom = input_feat.geometry()
output_geom = input_geom.Intersection(clipPoly)
# do something with output_geom, e.g. write to a layer
Best regards,
Lukas
On 19.05.2017 16:02, Tudorache, Marian wrote:
*Hi,*
I have tried to run clipping processing algorithm and it fails.
First version:
srs = qgis.core.QgsCoordinateReferenceSystem(4019, qgis.core.
QgsCoordinateReferenceSystem.EpsgCrsId)
#Input Layer
inputLayer = qgis.core.QgsVectorLayer(shapeFileLocation +
“/inputLineString.shp”, “inputLineString”, “ogr”)
inputLayer.setCrs(srs)
Clipping Layer:
clipLayer =
qgis.core.QgsVectorLayer(“Polygon?crs={0}”.format(srs.authid())
#algorithm to add a clipping polygon feature
#the algorithm works because I tested with clipLayer.getFeatures() and
I was able to extract the geometry and points
…..
….
#calling processing algorithm.
processing.runalg(‘qgis.clip’, inputLayer, clipLayer, “output.shp”)
The error:
Unable to execute algorithm
Wrong parameter value: Polygon?crs=ESPG:4019
Any idea why is not working?
Thank you,
Marian
------------------------------------------------------------------------
This electronic message, as well as any transmitted files included in
the electronic message, may contain privileged or confidential
information and is intended solely for the use of the individual(s) or
entity to which it is addressed. If you have received this electronic
message in error please notify the sender immediately and delete the
electronic message. Any unauthorized copying, disclosure or
distribution of the electronic message is strictly forbidden. NAV
CANADA accepts no liability for any damage caused by any virus and/or
other malicious code transmitted by this electronic communication.
Le présent message électronique et tout fichier qui peut y être joint
peuvent contenir des renseignements privilégiés ou confidentiels
destinés à l’usage exclusif des personnes ou des organismes à qui ils
s’adressent. Si vous avez reçu ce message électronique par erreur,
veuillez en informer l’expéditeur immédiatement et supprimez le. Toute
reproduction, divulgation ou distribution du présent message
électronique est strictement interdite. NAV CANADA n’assume aucune
responsabilité en cas de dommage causé par tout virus ou autre
programme malveillant transmis par ce message électronique.
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
--
Lukas Winiwarter TU Wien,
Stud. Ass. Department of Geodesy and
Tel: +43-(0)1-58801-12246 Geoinformation (E120),
Fax: +43-(0)1-58801-912246 Research Group Photogrammetry
Email: [email protected] Gußhausstraße 27-29
http://photo.geo.tuwien.ac.at/ 1040 Vienna, Austria
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user