[GRASS-user] Split polygons with lines

Shane Carey careyshan at gmail.com
Fri Mar 15 07:41:57 PDT 2019


Hey Moritz,

Thanks for coming back to me. I figured it out with the following script


import processing
polys = QgsVectorLayer(r"C:\Users\shane.carey\Desktop\poly.shp", 'poly',
'ogr')
lines = QgsVectorLayer(r"C:\Users\shane.carey\Desktop\s1line.shp", 'lines',
'ogr')
output = r"C:\Users\shane.carey\Desktop\split2.shp"
processing.run("saga:polygonlineintersection",{ 'POLYGONS':polys,
'LINES':lines,'INTERSECT':output})

Cheers
Le gach dea ghui,
*Shane Carey*
*GIS and Data Solutions Consultant*


On Fri, Mar 15, 2019 at 2:21 PM Moritz Lennert <mlennert at club.worldonline.be>
wrote:

> On 10/03/19 15:39, Shane Carey wrote:
> > Hi,
> >
> > I've been looking for ways of grass gis splitting a polygon into
> > multiplepolygons with a line shapefile and wondering are there tools in
> > Grass to do this!!
>
> Does the following correspond to what you are looking for ?
>
> test = polygons
> test2 = lines
>
> # patch lines and polygons together
> v.patch test,test2 out=test_patched
>
> # transform lines to boundaries
> v.type test_patched out=test_patched_bound
>
> # break boundaries at intersections
> v.clean test_patched_bound tool=break out=test_patched_bound_clean
>
> # add centroids to new areas
> v.centroids test_patched_bound_clean out=final
>
> This can be easily scripted into a small addon module.
>
> Moritz
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190315/0e78a0d9/attachment.html>


More information about the grass-user mailing list