[Qgis-developer] Intersection of line and polygon

Nyall Dawson nyall.dawson at gmail.com
Tue Nov 4 13:24:20 PST 2014


On 5 November 2014 08:09, Salvatore Larosa <lrssvtml at gmail.com> wrote:
> Hi,
>
> On Tue, Nov 4, 2014 at 8:36 PM, Nyall Dawson <nyall.dawson at gmail.com> wrote:
>> Hi all,
>>
>> Can someone give me a pointer to the best way to implement an intersection
>> between a line and a rectangle using QgsGeometry? The line may curve out of
>> the rectangle and then back in multiple times, so ideally I want to get a
>> collection of each part of the line which is within the rectangle.
>
> is there some trouble to use the intersection function of QgsGeometry()?
> should not to be enough line.intersection(rectangle)? or probably I am
> missing the question here? :)

Looking at the definition of QgsGeometry::intersection the docs state
"Returns a geometry representing the points shared by this geometry
and other.". I assume this method is designed for intersection of two
polygons, where someone is after the overlapping area.

Nyall


More information about the Qgis-developer mailing list