[Qgis-developer] [Python] splitGeometry

Bernhard Ströbl bernhard.stroebl at jena.de
Tue Jul 9 05:14:34 PDT 2013


Hi Denis,

thank you for the hint. It's true (newGeometries is misleading, though)
so for anyone interested, here is the relevant part of my code:

#split geometry
result, newGeometries, topoTestPoints =
myGeometry.splitGeometry(splitterPList, True)

#update the original feature
myFeature.setGeometry(myGeometry)
myLayer.updateFeature(myFeature)
# create new features for all new geometries
for aGeom in newGeometries:
   newFeature = QgsFeature()
   newFeature.setAttributes(myFeature.attributes())
   myLayer.addFeature(newFeature)

Bernhard


Am 09.07.2013 13:45, schrieb Denis Rouzaud:
> Hi Bernard,
>
> If I remember well, when you do myGeom.splitGeometry, it returns the
> splitted geometry which is removed from myGeom.
> So basically, you do have both parts.
>
> Cheers,
>
> Denis
>
> On 07/09/2013 01:15 PM, Bernhard Ströbl wrote:
>> Hi,
>>
>> I am trying to split a geometry (polygon) with a line, the line is
>> straight and crossing the polygon's boundary exactly twice; here is my
>> code:
>>
>> result, newGeometries, topoTestPoints =
>> myGeometry.splitGeometry(splitterPList, True)
>>
>> the result is 0 (OK) but newGeometries contains only _one_ polygon. I
>> was under the impression that newGeometries would contain _all_
>> polygons resulting from the split operation, i.e. the two halves at
>> each side of the line.
>> If this is the intended behaviour I think I can make a workaround with
>> myGeometry.difference(newGeometries[0]), if it is not I will file a
>> ticket.
>>
>> Bernhard
>>
>>
>> __________ Information from ESET Mail Security, version of virus
>> signature database 8544 (20130709) __________
>>
>> The message was checked by ESET Mail Security.
>> http://www.eset.com
>>
>>
>> _______________________________________________
>> Qgis-developer mailing list
>> Qgis-developer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
>
> __________ Information from ESET Mail Security, version of virus
> signature database 8545 (20130709) __________
>
> The message was checked by ESET Mail Security.
> http://www.eset.com
>
>




__________ Information from ESET Mail Security, version of virus signature database 8545 (20130709) __________

The message was checked by ESET Mail Security.
http://www.eset.com




More information about the Qgis-developer mailing list