Iterate an intersect between polylines and polygons in QGIS using Python script

المشرف العام

Administrator
طاقم الإدارة
I have a shapefile made up of 127 separate polygons that represent different districts. Overlaid on this layer is a polyline layer of 2800 streets, some which are completely bound by the polygons and some which crisscross two or more polygons.

My task is two find the total length of streets within each polygon (district). I've already done this with one district using Vector> Geoprocessing Tools > Intersect and then performing summary statsitics. However, in order to avoid doing this manually 127 times, I would like to write a script that will iterate through each polygon - performing the intersect with the polyline layer and leaving me with 127 separate shapefiles.

I not very familiar with Python - I only know some very basic commands. I've attached images to help you visualize and conceptualize the problem.





أكثر...
 
أعلى