[{"data":1,"prerenderedAt":1752},["ShallowReactive",2],{"doc:\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Fintersect-two-vector-layers-pyqgis":3},{"id":4,"title":5,"body":6,"description":1741,"extension":1742,"meta":1743,"navigation":206,"path":1748,"seo":1749,"stem":1750,"__hash__":1751},"docs\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Fintersect-two-vector-layers-pyqgis\u002Findex.md","Intersect Two Vector Layers in PyQGIS",{"type":7,"value":8,"toc":1726},"minimark",[9,13,17,31,135,140,158,162,165,396,419,423,435,502,699,716,720,723,903,913,917,920,1052,1066,1070,1081,1191,1196,1200,1203,1292,1428,1438,1442,1445,1579,1589,1593,1608,1612,1638,1642,1645,1649,1655,1666,1672,1678,1688,1692,1722],[10,11,5],"h1",{"id":12},"intersect-two-vector-layers-in-pyqgis",[14,15,16],"p",{},"Intersection is the overlay that answers \"how much of A lies in B\": how many hectares of each soil type fall inside each field, which length of each road runs through a flood zone, which part of each parcel is covered by a protection designation. The operation cuts features of one layer by the features of another and keeps only the overlapping pieces, each carrying attributes from both sides. It is one of the most used geoprocessing steps, and one whose output is easy to misread when areas are not recomputed or slivers are not filtered.",[14,18,19,20,25,26,30],{},"This recipe belongs to ",[21,22,24],"a",{"href":23},"\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002F","Vector Data Manipulation",". It runs ",[27,28,29],"code",{},"native:intersection",", controls which attributes are carried across, recomputes measurements on the pieces, filters slivers, deals with invalid input, and summarises the result into the table the question asked for.",[14,32,33],{},[34,35,40,44,48,55,64,74,80,86,91,96,103,109,116,122,127,131],"svg",{"viewBox":36,"role":37,"ariaLabel":38,"xmlns":39},"0 0 760 280","img","Fields and soil zones overlapping, with the intersection returning only the overlapping pieces that carry attributes from both layers","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg",[41,42,43],"title",{},"What an intersection returns",[45,46,47],"desc",{},"Two input layers, fields and soil zones, overlap. The intersection returns only the overlapping pieces: each piece is a part of one field that lies in one soil zone, carrying the field's attributes and the soil zone's attributes. Parts of fields outside every soil zone are dropped, as are parts of soil zones outside every field.",[49,50],"rect",{"x":51,"y":51,"width":52,"height":53,"fill":54},"0","760","280","#f6f3ea",[56,57,63],"text",{"x":58,"y":59,"style":60,"fill":61,"textAnchor":62},"380","28","text-anchor:middle;font-size:14px;font-family:sans-serif;font-weight:bold","#17211d","middle","Only the overlap, with attributes from both",[49,65],{"x":66,"y":67,"width":68,"height":69,"rx":70,"fill":71,"stroke":72,"style":73},"60","70","200","140","4","#eef7f4","#0f766e","stroke-width:2",[56,75,79],{"x":76,"y":77,"style":78,"fill":72,"textAnchor":62},"110","62","text-anchor:middle;font-size:10.5px;font-family:sans-serif","fields",[49,81],{"x":82,"y":76,"width":68,"height":69,"rx":70,"fill":83,"fillOpacity":84,"stroke":85,"style":73},"160","#fdf2e2",0.6,"#b45309",[56,87,90],{"x":88,"y":89,"style":78,"fill":85,"textAnchor":62},"300","268","soil zones",[56,92,95],{"x":58,"y":82,"style":93,"fill":94,"textAnchor":62},"text-anchor:middle;font-size:22.0px;font-family:sans-serif","#59645f","→",[49,97],{"x":98,"y":76,"width":99,"height":99,"rx":51,"fill":100,"stroke":101,"style":102},"460","100","#eff3ff","#2563eb","stroke-width:2.5",[56,104,108],{"x":105,"y":106,"style":107,"fill":101,"textAnchor":62},"510","165","text-anchor:middle;font-size:11.0px;font-family:sans-serif;font-weight:bold","piece",[49,110],{"x":111,"y":112,"width":113,"height":69,"rx":114,"fill":115,"stroke":94,"style":73},"590","90","146","8","#fffdf7",[56,117,121],{"x":118,"y":119,"style":120,"fill":61,"textAnchor":62},"663","121.78","text-anchor:middle;font-size:11.5px;font-family:sans-serif;font-weight:bold","attributes",[56,123,126],{"x":118,"y":124,"style":78,"fill":125,"textAnchor":62},"149.78","#2f3b35","field_id",[56,128,130],{"x":118,"y":129,"style":78,"fill":125,"textAnchor":62},"177.78","crop",[56,132,134],{"x":118,"y":133,"style":78,"fill":125,"textAnchor":62},"205.78","soil_type",[136,137,139],"h2",{"id":138},"prerequisites","Prerequisites",[141,142,143,147,150],"ul",{},[144,145,146],"li",{},"QGIS 3.34 LTR or newer, or the QGIS 4 series.",[144,148,149],{},"Two layers in the same projected CRS. Processing reprojects the overlay on the fly when CRSs differ, but measuring areas in a geographic CRS gives meaningless numbers, so reproject first if needed.",[144,151,152,153,157],{},"Valid geometries in both layers; a ",[21,154,156],{"href":155},"\u002Fspatial-data-processing-automation\u002Fdata-quality-and-topology-validation\u002Fcheck-geometry-validity-report-pyqgis\u002F","validity report"," takes seconds.",[136,159,161],{"id":160},"run-the-intersection","Run the intersection",[14,163,164],{},"The algorithm takes an input layer, an overlay layer and optional lists of fields to keep from each.",[166,167,172],"pre",{"className":168,"code":169,"language":170,"meta":171,"style":171},"language-python shiki shiki-themes github-dark","import processing\nfrom qgis.core import QgsProject\n\nfields_layer = QgsProject.instance().mapLayersByName(\"fields\")[0]\nsoils = QgsProject.instance().mapLayersByName(\"soil_zones\")[0]\n\npieces = processing.run(\"native:intersection\", {\n    \"INPUT\": fields_layer,\n    \"OVERLAY\": soils,\n    \"INPUT_FIELDS\": [\"field_id\", \"crop\"],\n    \"OVERLAY_FIELDS\": [\"soil_type\", \"drainage\"],\n    \"OVERLAY_FIELDS_PREFIX\": \"\",\n    \"OUTPUT\": \"memory:fields_x_soils\",\n})[\"OUTPUT\"]\n\nprint(pieces.featureCount(), \"pieces;\", pieces.fields().names())\nQgsProject.instance().addMapLayer(pieces)\n","python","",[27,173,174,187,201,208,233,252,257,274,283,292,313,331,346,359,370,375,390],{"__ignoreMap":171},[175,176,179,183],"span",{"class":177,"line":178},"line",1,[175,180,182],{"class":181},"snl16","import",[175,184,186],{"class":185},"s95oV"," processing\n",[175,188,190,193,196,198],{"class":177,"line":189},2,[175,191,192],{"class":181},"from",[175,194,195],{"class":185}," qgis.core ",[175,197,182],{"class":181},[175,199,200],{"class":185}," QgsProject\n",[175,202,204],{"class":177,"line":203},3,[175,205,207],{"emptyLinePlaceholder":206},true,"\n",[175,209,211,214,217,220,224,227,230],{"class":177,"line":210},4,[175,212,213],{"class":185},"fields_layer ",[175,215,216],{"class":181},"=",[175,218,219],{"class":185}," QgsProject.instance().mapLayersByName(",[175,221,223],{"class":222},"sU2Wk","\"fields\"",[175,225,226],{"class":185},")[",[175,228,51],{"class":229},"sDLfK",[175,231,232],{"class":185},"]\n",[175,234,236,239,241,243,246,248,250],{"class":177,"line":235},5,[175,237,238],{"class":185},"soils ",[175,240,216],{"class":181},[175,242,219],{"class":185},[175,244,245],{"class":222},"\"soil_zones\"",[175,247,226],{"class":185},[175,249,51],{"class":229},[175,251,232],{"class":185},[175,253,255],{"class":177,"line":254},6,[175,256,207],{"emptyLinePlaceholder":206},[175,258,260,263,265,268,271],{"class":177,"line":259},7,[175,261,262],{"class":185},"pieces ",[175,264,216],{"class":181},[175,266,267],{"class":185}," processing.run(",[175,269,270],{"class":222},"\"native:intersection\"",[175,272,273],{"class":185},", {\n",[175,275,277,280],{"class":177,"line":276},8,[175,278,279],{"class":222},"    \"INPUT\"",[175,281,282],{"class":185},": fields_layer,\n",[175,284,286,289],{"class":177,"line":285},9,[175,287,288],{"class":222},"    \"OVERLAY\"",[175,290,291],{"class":185},": soils,\n",[175,293,295,298,301,304,307,310],{"class":177,"line":294},10,[175,296,297],{"class":222},"    \"INPUT_FIELDS\"",[175,299,300],{"class":185},": [",[175,302,303],{"class":222},"\"field_id\"",[175,305,306],{"class":185},", ",[175,308,309],{"class":222},"\"crop\"",[175,311,312],{"class":185},"],\n",[175,314,316,319,321,324,326,329],{"class":177,"line":315},11,[175,317,318],{"class":222},"    \"OVERLAY_FIELDS\"",[175,320,300],{"class":185},[175,322,323],{"class":222},"\"soil_type\"",[175,325,306],{"class":185},[175,327,328],{"class":222},"\"drainage\"",[175,330,312],{"class":185},[175,332,334,337,340,343],{"class":177,"line":333},12,[175,335,336],{"class":222},"    \"OVERLAY_FIELDS_PREFIX\"",[175,338,339],{"class":185},": ",[175,341,342],{"class":222},"\"\"",[175,344,345],{"class":185},",\n",[175,347,349,352,354,357],{"class":177,"line":348},13,[175,350,351],{"class":222},"    \"OUTPUT\"",[175,353,339],{"class":185},[175,355,356],{"class":222},"\"memory:fields_x_soils\"",[175,358,345],{"class":185},[175,360,362,365,368],{"class":177,"line":361},14,[175,363,364],{"class":185},"})[",[175,366,367],{"class":222},"\"OUTPUT\"",[175,369,232],{"class":185},[175,371,373],{"class":177,"line":372},15,[175,374,207],{"emptyLinePlaceholder":206},[175,376,378,381,384,387],{"class":177,"line":377},16,[175,379,380],{"class":229},"print",[175,382,383],{"class":185},"(pieces.featureCount(), ",[175,385,386],{"class":222},"\"pieces;\"",[175,388,389],{"class":185},", pieces.fields().names())\n",[175,391,393],{"class":177,"line":392},17,[175,394,395],{"class":185},"QgsProject.instance().addMapLayer(pieces)\n",[14,397,398,402,403,406,407,410,411,414,415,418],{},[399,400,401],"strong",{},"Breakdown:"," Each output feature is the geometric intersection of one input feature with one overlay feature, so a field lying across three soil zones becomes three pieces. Listing fields explicitly keeps the output narrow and readable; empty lists keep all fields from that side. ",[27,404,405],{},"OVERLAY_FIELDS_PREFIX"," adds a prefix such as ",[27,408,409],{},"soil_"," to overlay field names, which avoids clashes when both layers have a field called ",[27,412,413],{},"name"," or ",[27,416,417],{},"id",". The output geometry type follows the input: intersecting polygons with polygons gives polygons, lines with polygons gives lines.",[136,420,422],{"id":421},"recompute-measurements-on-the-pieces","Recompute measurements on the pieces",[14,424,425,426,430,431,434],{},"Attributes copied from the inputs describe the ",[427,428,429],"em",{},"whole"," original features. An ",[27,432,433],{},"area_ha"," field from the fields layer still holds the whole field's area on every piece — the most common mistake in overlay analysis.",[14,436,437],{},[34,438,441,444,447,450,453,459,464,468,472,476,480,485,490,493,496,499],{"viewBox":439,"role":37,"ariaLabel":440,"xmlns":39},"0 0 760 240","A 12 hectare field cut into three pieces, where copied area fields would sum to 36 and recomputed areas sum correctly to 12",[41,442,443],{},"Copied areas are wrong after cutting",[45,445,446],{},"A field of 12 hectares is cut into three pieces of 5, 4 and 3 hectares. If the input's area field is copied, every piece claims 12 hectares and a sum gives 36. Recomputing area on each piece gives 5, 4 and 3, which sum correctly to 12.",[49,448],{"x":51,"y":51,"width":52,"height":449,"fill":54},"240",[56,451,452],{"x":58,"y":59,"style":60,"fill":61,"textAnchor":62},"Recompute after every overlay",[49,454],{"x":455,"y":456,"width":457,"height":82,"rx":114,"fill":83,"stroke":458,"style":73},"24","56","340","#b91c1c",[56,460,463],{"x":461,"y":462,"style":120,"fill":458,"textAnchor":62},"194","87.78","copied field",[56,465,467],{"x":461,"y":466,"style":78,"fill":125,"textAnchor":62},"113.78","piece 1: 12 ha",[56,469,471],{"x":461,"y":470,"style":78,"fill":125,"textAnchor":62},"139.78","piece 2: 12 ha",[56,473,475],{"x":461,"y":474,"style":78,"fill":125,"textAnchor":62},"165.78","piece 3: 12 ha",[56,477,479],{"x":461,"y":478,"style":78,"fill":94,"textAnchor":62},"191.78","sum: 36 ha ✗",[49,481],{"x":482,"y":456,"width":457,"height":82,"rx":114,"fill":483,"stroke":484,"style":73},"396","#e8efe6","#15803d",[56,486,489],{"x":487,"y":462,"style":120,"fill":488,"textAnchor":62},"566","#166534","recomputed $area",[56,491,492],{"x":487,"y":466,"style":78,"fill":125,"textAnchor":62},"piece 1: 5 ha",[56,494,495],{"x":487,"y":470,"style":78,"fill":125,"textAnchor":62},"piece 2: 4 ha",[56,497,498],{"x":487,"y":474,"style":78,"fill":125,"textAnchor":62},"piece 3: 3 ha",[56,500,501],{"x":487,"y":478,"style":78,"fill":94,"textAnchor":62},"sum: 12 ha ✓",[166,503,505],{"className":168,"code":504,"language":170,"meta":171,"style":171},"measured = processing.run(\"native:fieldcalculator\", {\n    \"INPUT\": pieces, \"FIELD_NAME\": \"piece_ha\", \"FIELD_TYPE\": 0,\n    \"FIELD_LENGTH\": 12, \"FIELD_PRECISION\": 4,\n    \"FORMULA\": \"$area \u002F 10000\",\n    \"OUTPUT\": \"memory:fields_x_soils_measured\"})[\"OUTPUT\"]\n\ntotal_pieces = sum(f[\"piece_ha\"] for f in measured.getFeatures())\ntotal_fields = sum(f.geometry().area() for f in fields_layer.getFeatures()) \u002F 1e4\nprint(f\"pieces {total_pieces:,.1f} ha of {total_fields:,.1f} ha of fields\")\n",[27,506,507,521,547,568,580,595,599,629,656],{"__ignoreMap":171},[175,508,509,512,514,516,519],{"class":177,"line":178},[175,510,511],{"class":185},"measured ",[175,513,216],{"class":181},[175,515,267],{"class":185},[175,517,518],{"class":222},"\"native:fieldcalculator\"",[175,520,273],{"class":185},[175,522,523,525,528,531,533,536,538,541,543,545],{"class":177,"line":189},[175,524,279],{"class":222},[175,526,527],{"class":185},": pieces, ",[175,529,530],{"class":222},"\"FIELD_NAME\"",[175,532,339],{"class":185},[175,534,535],{"class":222},"\"piece_ha\"",[175,537,306],{"class":185},[175,539,540],{"class":222},"\"FIELD_TYPE\"",[175,542,339],{"class":185},[175,544,51],{"class":229},[175,546,345],{"class":185},[175,548,549,552,554,557,559,562,564,566],{"class":177,"line":203},[175,550,551],{"class":222},"    \"FIELD_LENGTH\"",[175,553,339],{"class":185},[175,555,556],{"class":229},"12",[175,558,306],{"class":185},[175,560,561],{"class":222},"\"FIELD_PRECISION\"",[175,563,339],{"class":185},[175,565,70],{"class":229},[175,567,345],{"class":185},[175,569,570,573,575,578],{"class":177,"line":210},[175,571,572],{"class":222},"    \"FORMULA\"",[175,574,339],{"class":185},[175,576,577],{"class":222},"\"$area \u002F 10000\"",[175,579,345],{"class":185},[175,581,582,584,586,589,591,593],{"class":177,"line":235},[175,583,351],{"class":222},[175,585,339],{"class":185},[175,587,588],{"class":222},"\"memory:fields_x_soils_measured\"",[175,590,364],{"class":185},[175,592,367],{"class":222},[175,594,232],{"class":185},[175,596,597],{"class":177,"line":254},[175,598,207],{"emptyLinePlaceholder":206},[175,600,601,604,606,609,612,614,617,620,623,626],{"class":177,"line":259},[175,602,603],{"class":185},"total_pieces ",[175,605,216],{"class":181},[175,607,608],{"class":229}," sum",[175,610,611],{"class":185},"(f[",[175,613,535],{"class":222},[175,615,616],{"class":185},"] ",[175,618,619],{"class":181},"for",[175,621,622],{"class":185}," f ",[175,624,625],{"class":181},"in",[175,627,628],{"class":185}," measured.getFeatures())\n",[175,630,631,634,636,638,641,643,645,647,650,653],{"class":177,"line":276},[175,632,633],{"class":185},"total_fields ",[175,635,216],{"class":181},[175,637,608],{"class":229},[175,639,640],{"class":185},"(f.geometry().area() ",[175,642,619],{"class":181},[175,644,622],{"class":185},[175,646,625],{"class":181},[175,648,649],{"class":185}," fields_layer.getFeatures()) ",[175,651,652],{"class":181},"\u002F",[175,654,655],{"class":229}," 1e4\n",[175,657,658,660,663,666,669,672,675,678,681,684,686,689,691,693,696],{"class":177,"line":285},[175,659,380],{"class":229},[175,661,662],{"class":185},"(",[175,664,665],{"class":181},"f",[175,667,668],{"class":222},"\"pieces ",[175,670,671],{"class":229},"{",[175,673,674],{"class":185},"total_pieces",[175,676,677],{"class":181},":,.1f",[175,679,680],{"class":229},"}",[175,682,683],{"class":222}," ha of ",[175,685,671],{"class":229},[175,687,688],{"class":185},"total_fields",[175,690,677],{"class":181},[175,692,680],{"class":229},[175,694,695],{"class":222}," ha of fields\"",[175,697,698],{"class":185},")\n",[14,700,701,703,704,707,708,711,712,715],{},[399,702,401],{}," ",[27,705,706],{},"$area"," measures each piece using the project's ellipsoid settings; ",[27,709,710],{},"area($geometry)"," gives planar area in layer units, which is what you want when the layer is in an equal-area or local projected CRS. Comparing the total of the pieces with the total of the inputs is a quick sanity check: the pieces can only add up to less than or equal to the fields' area, the difference being the parts outside every soil zone. For line layers, recompute ",[27,713,714],{},"$length"," the same way.",[136,717,719],{"id":718},"filter-slivers","Filter slivers",[14,721,722],{},"Where two layers were digitized independently, their boundaries rarely coincide exactly. Intersection then produces slivers — thin pieces along shared boundaries that are artefacts, not real overlaps.",[166,724,726],{"className":168,"code":725,"language":170,"meta":171,"style":171},"import math\n\ndef thinness(g):\n    p = g.length()\n    return 4 * math.pi * g.area() \u002F (p * p) if p else 0\n\nslivers = [f.id() for f in measured.getFeatures()\n           if f[\"piece_ha\"] \u003C 0.01 or thinness(f.geometry()) \u003C 0.05]\nprint(len(slivers), \"probable slivers out of\", measured.featureCount())\n\nfrom qgis.core import edit\nwith edit(measured):\n    measured.deleteFeatures(slivers)\n",[27,727,728,735,739,751,761,803,807,826,857,875,879,890,898],{"__ignoreMap":171},[175,729,730,732],{"class":177,"line":178},[175,731,182],{"class":181},[175,733,734],{"class":185}," math\n",[175,736,737],{"class":177,"line":189},[175,738,207],{"emptyLinePlaceholder":206},[175,740,741,744,748],{"class":177,"line":203},[175,742,743],{"class":181},"def",[175,745,747],{"class":746},"svObZ"," thinness",[175,749,750],{"class":185},"(g):\n",[175,752,753,756,758],{"class":177,"line":210},[175,754,755],{"class":185},"    p ",[175,757,216],{"class":181},[175,759,760],{"class":185}," g.length()\n",[175,762,763,766,769,772,775,778,781,783,786,788,791,794,797,800],{"class":177,"line":235},[175,764,765],{"class":181},"    return",[175,767,768],{"class":229}," 4",[175,770,771],{"class":181}," *",[175,773,774],{"class":185}," math.pi ",[175,776,777],{"class":181},"*",[175,779,780],{"class":185}," g.area() ",[175,782,652],{"class":181},[175,784,785],{"class":185}," (p ",[175,787,777],{"class":181},[175,789,790],{"class":185}," p) ",[175,792,793],{"class":181},"if",[175,795,796],{"class":185}," p ",[175,798,799],{"class":181},"else",[175,801,802],{"class":229}," 0\n",[175,804,805],{"class":177,"line":254},[175,806,207],{"emptyLinePlaceholder":206},[175,808,809,812,814,817,819,821,823],{"class":177,"line":259},[175,810,811],{"class":185},"slivers ",[175,813,216],{"class":181},[175,815,816],{"class":185}," [f.id() ",[175,818,619],{"class":181},[175,820,622],{"class":185},[175,822,625],{"class":181},[175,824,825],{"class":185}," measured.getFeatures()\n",[175,827,828,831,834,836,838,841,844,847,850,852,855],{"class":177,"line":276},[175,829,830],{"class":181},"           if",[175,832,833],{"class":185}," f[",[175,835,535],{"class":222},[175,837,616],{"class":185},[175,839,840],{"class":181},"\u003C",[175,842,843],{"class":229}," 0.01",[175,845,846],{"class":181}," or",[175,848,849],{"class":185}," thinness(f.geometry()) ",[175,851,840],{"class":181},[175,853,854],{"class":229}," 0.05",[175,856,232],{"class":185},[175,858,859,861,863,866,869,872],{"class":177,"line":285},[175,860,380],{"class":229},[175,862,662],{"class":185},[175,864,865],{"class":229},"len",[175,867,868],{"class":185},"(slivers), ",[175,870,871],{"class":222},"\"probable slivers out of\"",[175,873,874],{"class":185},", measured.featureCount())\n",[175,876,877],{"class":177,"line":294},[175,878,207],{"emptyLinePlaceholder":206},[175,880,881,883,885,887],{"class":177,"line":315},[175,882,192],{"class":181},[175,884,195],{"class":185},[175,886,182],{"class":181},[175,888,889],{"class":185}," edit\n",[175,891,892,895],{"class":177,"line":333},[175,893,894],{"class":181},"with",[175,896,897],{"class":185}," edit(measured):\n",[175,899,900],{"class":177,"line":348},[175,901,902],{"class":185},"    measured.deleteFeatures(slivers)\n",[14,904,905,907,908,912],{},[399,906,401],{}," Very small pieces (here under 100 m²) and very thin ones (low isoperimetric quotient) are almost always boundary mismatch. Choose thresholds from the data's accuracy rather than by eye; reporting how many pieces and how much area were removed keeps the cleanup honest. The better long-term fix is to make the layers agree first by ",[21,909,911],{"href":910},"\u002Fspatial-data-processing-automation\u002Fdata-quality-and-topology-validation\u002Fsnap-geometries-to-layer-pyqgis\u002F","snapping one to the other",", after which slivers mostly disappear.",[136,914,916],{"id":915},"handle-invalid-input","Handle invalid input",[14,918,919],{},"Overlays are where invalid geometries fail loudly — or worse, quietly lose features. Processing's invalid-feature setting decides what happens; setting it explicitly in a script makes the behaviour predictable.",[166,921,923],{"className":168,"code":922,"language":170,"meta":171,"style":171},"from qgis.core import QgsProcessingContext, QgsFeatureRequest, QgsProcessingFeedback\n\ncontext = QgsProcessingContext()\ncontext.setInvalidGeometryCheck(QgsFeatureRequest.GeometryAbortOnInvalid)\nfeedback = QgsProcessingFeedback()\ntry:\n    processing.run(\"native:intersection\", {\n        \"INPUT\": fields_layer, \"OVERLAY\": soils, \"OUTPUT\": \"memory:\"},\n        context=context, feedback=feedback)\nexcept Exception as err:\n    print(\"invalid geometry stopped the run:\", err)\n",[27,924,925,936,940,950,955,965,973,982,1006,1025,1039],{"__ignoreMap":171},[175,926,927,929,931,933],{"class":177,"line":178},[175,928,192],{"class":181},[175,930,195],{"class":185},[175,932,182],{"class":181},[175,934,935],{"class":185}," QgsProcessingContext, QgsFeatureRequest, QgsProcessingFeedback\n",[175,937,938],{"class":177,"line":189},[175,939,207],{"emptyLinePlaceholder":206},[175,941,942,945,947],{"class":177,"line":203},[175,943,944],{"class":185},"context ",[175,946,216],{"class":181},[175,948,949],{"class":185}," QgsProcessingContext()\n",[175,951,952],{"class":177,"line":210},[175,953,954],{"class":185},"context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryAbortOnInvalid)\n",[175,956,957,960,962],{"class":177,"line":235},[175,958,959],{"class":185},"feedback ",[175,961,216],{"class":181},[175,963,964],{"class":185}," QgsProcessingFeedback()\n",[175,966,967,970],{"class":177,"line":254},[175,968,969],{"class":181},"try",[175,971,972],{"class":185},":\n",[175,974,975,978,980],{"class":177,"line":259},[175,976,977],{"class":185},"    processing.run(",[175,979,270],{"class":222},[175,981,273],{"class":185},[175,983,984,987,990,993,996,998,1000,1003],{"class":177,"line":276},[175,985,986],{"class":222},"        \"INPUT\"",[175,988,989],{"class":185},": fields_layer, ",[175,991,992],{"class":222},"\"OVERLAY\"",[175,994,995],{"class":185},": soils, ",[175,997,367],{"class":222},[175,999,339],{"class":185},[175,1001,1002],{"class":222},"\"memory:\"",[175,1004,1005],{"class":185},"},\n",[175,1007,1008,1012,1014,1017,1020,1022],{"class":177,"line":285},[175,1009,1011],{"class":1010},"s9osk","        context",[175,1013,216],{"class":181},[175,1015,1016],{"class":185},"context, ",[175,1018,1019],{"class":1010},"feedback",[175,1021,216],{"class":181},[175,1023,1024],{"class":185},"feedback)\n",[175,1026,1027,1030,1033,1036],{"class":177,"line":294},[175,1028,1029],{"class":181},"except",[175,1031,1032],{"class":229}," Exception",[175,1034,1035],{"class":181}," as",[175,1037,1038],{"class":185}," err:\n",[175,1040,1041,1044,1046,1049],{"class":177,"line":315},[175,1042,1043],{"class":229},"    print",[175,1045,662],{"class":185},[175,1047,1048],{"class":222},"\"invalid geometry stopped the run:\"",[175,1050,1051],{"class":185},", err)\n",[14,1053,1054,1056,1057,1060,1061,1065],{},[399,1055,401],{}," Aborting on invalid geometry is the safe setting for production scripts: a run either succeeds on clean data or stops with a clear message. The alternatives — skipping invalid features or ignoring the check — produce a result that silently lacks some features or contains wrong pieces. Fix the input with ",[27,1058,1059],{},"native:fixgeometries"," and run again, as described in ",[21,1062,1064],{"href":1063},"\u002Fspatial-data-processing-automation\u002Fgeometry-operations-and-predicates\u002Ffix-invalid-geometries-pyqgis\u002F","fixing invalid geometries",".",[136,1067,1069],{"id":1068},"intersect-with-several-overlays-at-once","Intersect with several overlays at once",[14,1071,1072,1073,1076,1077,1080],{},"Questions often involve more than two layers: the parts of each field that are on clay soil, inside a water-protection zone ",[427,1074,1075],{},"and"," below 200 m elevation. Chaining pairwise intersections works, but ",[27,1078,1079],{},"native:multiintersection"," overlays several layers in one call and keeps attributes from all of them.",[166,1082,1084],{"className":168,"code":1083,"language":170,"meta":171,"style":171},"protection = QgsProject.instance().mapLayersByName(\"water_protection\")[0]\nlowland = QgsProject.instance().mapLayersByName(\"below_200m\")[0]\n\ncombined = processing.run(\"native:multiintersection\", {\n    \"INPUT\": fields_layer,\n    \"OVERLAYS\": [soils, protection, lowland],\n    \"OVERLAY_FIELDS_PREFIX\": \"\",\n    \"OUTPUT\": \"memory:fields_all_overlays\"})[\"OUTPUT\"]\nprint(combined.featureCount(), \"pieces inside all three overlays\")\n",[27,1085,1086,1104,1122,1126,1140,1146,1154,1164,1179],{"__ignoreMap":171},[175,1087,1088,1091,1093,1095,1098,1100,1102],{"class":177,"line":178},[175,1089,1090],{"class":185},"protection ",[175,1092,216],{"class":181},[175,1094,219],{"class":185},[175,1096,1097],{"class":222},"\"water_protection\"",[175,1099,226],{"class":185},[175,1101,51],{"class":229},[175,1103,232],{"class":185},[175,1105,1106,1109,1111,1113,1116,1118,1120],{"class":177,"line":189},[175,1107,1108],{"class":185},"lowland ",[175,1110,216],{"class":181},[175,1112,219],{"class":185},[175,1114,1115],{"class":222},"\"below_200m\"",[175,1117,226],{"class":185},[175,1119,51],{"class":229},[175,1121,232],{"class":185},[175,1123,1124],{"class":177,"line":203},[175,1125,207],{"emptyLinePlaceholder":206},[175,1127,1128,1131,1133,1135,1138],{"class":177,"line":210},[175,1129,1130],{"class":185},"combined ",[175,1132,216],{"class":181},[175,1134,267],{"class":185},[175,1136,1137],{"class":222},"\"native:multiintersection\"",[175,1139,273],{"class":185},[175,1141,1142,1144],{"class":177,"line":235},[175,1143,279],{"class":222},[175,1145,282],{"class":185},[175,1147,1148,1151],{"class":177,"line":254},[175,1149,1150],{"class":222},"    \"OVERLAYS\"",[175,1152,1153],{"class":185},": [soils, protection, lowland],\n",[175,1155,1156,1158,1160,1162],{"class":177,"line":259},[175,1157,336],{"class":222},[175,1159,339],{"class":185},[175,1161,342],{"class":222},[175,1163,345],{"class":185},[175,1165,1166,1168,1170,1173,1175,1177],{"class":177,"line":276},[175,1167,351],{"class":222},[175,1169,339],{"class":185},[175,1171,1172],{"class":222},"\"memory:fields_all_overlays\"",[175,1174,364],{"class":185},[175,1176,367],{"class":222},[175,1178,232],{"class":185},[175,1180,1181,1183,1186,1189],{"class":177,"line":285},[175,1182,380],{"class":229},[175,1184,1185],{"class":185},"(combined.featureCount(), ",[175,1187,1188],{"class":222},"\"pieces inside all three overlays\"",[175,1190,698],{"class":185},[14,1192,1193,1195],{},[399,1194,401],{}," Each output piece lies inside the input feature and at least one feature of every overlay, so only the area satisfying all conditions remains — an \"and\" across layers. Attributes from every overlay are appended, which is why a prefix or a careful field selection beforehand matters when overlays share field names. One call is easier to read than three chained ones and avoids writing intermediate layers, though the measurement and sliver steps above still apply to the result. For \"or\" logic — inside any of several zones — dissolve the overlays into one layer first and intersect with that.",[136,1197,1199],{"id":1198},"summarise-the-result","Summarise the result",[14,1201,1202],{},"The intersection is rarely the final answer. The question — hectares of each soil type per crop, or per field — is a group-by over the pieces.",[14,1204,1205],{},[34,1206,1209,1212,1215,1218,1233,1236,1240,1245,1249,1252,1257,1260,1264,1267,1270,1274,1278,1283,1288],{"viewBox":1207,"role":37,"ariaLabel":1208,"xmlns":39},"0 0 760 196","Pieces with recomputed areas grouped by crop and soil type into a summary table of hectares",[41,1210,1211],{},"From pieces to a summary table",[45,1213,1214],{},"The pieces layer has one row per field and soil combination with recomputed area. Grouping by crop and soil type and summing area gives a compact table of hectares, for example wheat on clay 120 hectares, wheat on loam 340 hectares. The table answers the question; the pieces layer remains for mapping.",[49,1216],{"x":51,"y":51,"width":52,"height":1217,"fill":54},"196",[1219,1220,1221],"defs",{},[1222,1223,1229],"marker",{"id":1224,"viewBox":1225,"refX":114,"refY":1226,"markerWidth":1227,"markerHeight":1227,"orient":1228},"intSumArrow","0 0 10 10","5","7","auto-start-reverse",[1230,1231],"path",{"d":1232,"fill":125},"M0 0 L10 5 L0 10 z",[56,1234,1235],{"x":58,"y":59,"style":60,"fill":61,"textAnchor":62},"Group the pieces to answer the question",[49,1237],{"x":455,"y":66,"width":1238,"height":1239,"rx":114,"fill":115,"stroke":94,"style":73},"222","120",[56,1241,1244],{"x":1242,"y":1243,"style":120,"fill":61,"textAnchor":62},"135","97.78","pieces",[56,1246,1248],{"x":1242,"y":1247,"style":78,"fill":94,"textAnchor":62},"123.78","field × soil",[56,1250,1251],{"x":1242,"y":124,"style":78,"fill":94,"textAnchor":62},"piece_ha",[177,1253],{"x1":1254,"y1":1239,"x2":1255,"y2":1239,"stroke":125,"style":1256},"246","288","stroke-width:1.8;marker-end:url(#intSumArrow)",[49,1258],{"x":1259,"y":66,"width":68,"height":1239,"rx":114,"fill":71,"stroke":72,"style":73},"292",[56,1261,1263],{"x":1262,"y":1243,"style":120,"fill":72,"textAnchor":62},"392","group by",[56,1265,1266],{"x":1262,"y":1247,"style":78,"fill":125,"textAnchor":62},"crop, soil_type",[56,1268,1269],{"x":1262,"y":124,"style":78,"fill":94,"textAnchor":62},"sum piece_ha",[177,1271],{"x1":1272,"y1":1239,"x2":1273,"y2":1239,"stroke":125,"style":1256},"492","534",[49,1275],{"x":1276,"y":66,"width":1277,"height":1239,"rx":114,"fill":483,"stroke":484,"style":73},"538","198",[56,1279,1282],{"x":1280,"y":1281,"style":107,"fill":488,"textAnchor":62},"637","97.6","summary",[56,1284,1287],{"x":1280,"y":1285,"style":1286,"fill":125,"textAnchor":62},"123.6","text-anchor:middle;font-size:10.0px;font-family:sans-serif","wheat · clay 120 ha",[56,1289,1291],{"x":1280,"y":1290,"style":1286,"fill":125,"textAnchor":62},"149.6","wheat · loam 340 ha",[166,1293,1295],{"className":168,"code":1294,"language":170,"meta":171,"style":171},"from collections import defaultdict\n\ntable = defaultdict(float)\nfor f in measured.getFeatures():\n    table[(f[\"crop\"], f[\"soil_type\"])] += f[\"piece_ha\"]\n\nfor (crop, soil), ha in sorted(table.items()):\n    print(f\"{crop:\u003C12} {soil:\u003C10} {ha:10.1f} ha\")\n",[27,1296,1297,1309,1313,1328,1339,1363,1367,1382],{"__ignoreMap":171},[175,1298,1299,1301,1304,1306],{"class":177,"line":178},[175,1300,192],{"class":181},[175,1302,1303],{"class":185}," collections ",[175,1305,182],{"class":181},[175,1307,1308],{"class":185}," defaultdict\n",[175,1310,1311],{"class":177,"line":189},[175,1312,207],{"emptyLinePlaceholder":206},[175,1314,1315,1318,1320,1323,1326],{"class":177,"line":203},[175,1316,1317],{"class":185},"table ",[175,1319,216],{"class":181},[175,1321,1322],{"class":185}," defaultdict(",[175,1324,1325],{"class":229},"float",[175,1327,698],{"class":185},[175,1329,1330,1332,1334,1336],{"class":177,"line":210},[175,1331,619],{"class":181},[175,1333,622],{"class":185},[175,1335,625],{"class":181},[175,1337,1338],{"class":185}," measured.getFeatures():\n",[175,1340,1341,1344,1346,1349,1351,1354,1357,1359,1361],{"class":177,"line":235},[175,1342,1343],{"class":185},"    table[(f[",[175,1345,309],{"class":222},[175,1347,1348],{"class":185},"], f[",[175,1350,323],{"class":222},[175,1352,1353],{"class":185},"])] ",[175,1355,1356],{"class":181},"+=",[175,1358,833],{"class":185},[175,1360,535],{"class":222},[175,1362,232],{"class":185},[175,1364,1365],{"class":177,"line":254},[175,1366,207],{"emptyLinePlaceholder":206},[175,1368,1369,1371,1374,1376,1379],{"class":177,"line":259},[175,1370,619],{"class":181},[175,1372,1373],{"class":185}," (crop, soil), ha ",[175,1375,625],{"class":181},[175,1377,1378],{"class":229}," sorted",[175,1380,1381],{"class":185},"(table.items()):\n",[175,1383,1384,1386,1388,1390,1393,1395,1397,1400,1402,1405,1408,1411,1413,1415,1418,1421,1423,1426],{"class":177,"line":276},[175,1385,1043],{"class":229},[175,1387,662],{"class":185},[175,1389,665],{"class":181},[175,1391,1392],{"class":222},"\"",[175,1394,671],{"class":229},[175,1396,130],{"class":185},[175,1398,1399],{"class":181},":\u003C12",[175,1401,680],{"class":229},[175,1403,1404],{"class":229}," {",[175,1406,1407],{"class":185},"soil",[175,1409,1410],{"class":181},":\u003C10",[175,1412,680],{"class":229},[175,1414,1404],{"class":229},[175,1416,1417],{"class":185},"ha",[175,1419,1420],{"class":181},":10.1f",[175,1422,680],{"class":229},[175,1424,1425],{"class":222}," ha\"",[175,1427,698],{"class":185},[14,1429,1430,1432,1433,1437],{},[399,1431,401],{}," Summing recomputed piece areas by the attribute combination of interest produces the table directly. For larger tables or further analysis, the pieces can go to pandas as in ",[21,1434,1436],{"href":1435},"\u002Fspatial-data-processing-automation\u002Fpyqgis-and-the-python-data-stack\u002Fanalyse-attribute-table-with-pandas-pyqgis\u002F","analysing an attribute table with pandas",". Keep the pieces layer: it lets readers check any number in the table by looking at the map.",[136,1439,1441],{"id":1440},"intersect-a-layer-with-itself","Intersect a layer with itself",[14,1443,1444],{},"Overlaps within one layer — conflicting designations, double-digitized parcels — are found by intersecting a layer with itself and discarding each feature's intersection with itself.",[166,1446,1448],{"className":168,"code":1447,"language":170,"meta":171,"style":171},"self_overlaps = processing.run(\"native:intersection\", {\n    \"INPUT\": soils, \"OVERLAY\": soils,\n    \"INPUT_FIELDS\": [\"zone_id\"], \"OVERLAY_FIELDS\": [\"zone_id\"],\n    \"OVERLAY_FIELDS_PREFIX\": \"other_\", \"OUTPUT\": \"memory:\"})[\"OUTPUT\"]\nreal = [f for f in self_overlaps.getFeatures() if f[\"zone_id\"] != f[\"other_zone_id\"]]\nprint(len(real) \u002F\u002F 2, \"overlapping pairs of soil zones\")\n",[27,1449,1450,1463,1473,1494,1517,1555],{"__ignoreMap":171},[175,1451,1452,1455,1457,1459,1461],{"class":177,"line":178},[175,1453,1454],{"class":185},"self_overlaps ",[175,1456,216],{"class":181},[175,1458,267],{"class":185},[175,1460,270],{"class":222},[175,1462,273],{"class":185},[175,1464,1465,1467,1469,1471],{"class":177,"line":189},[175,1466,279],{"class":222},[175,1468,995],{"class":185},[175,1470,992],{"class":222},[175,1472,291],{"class":185},[175,1474,1475,1477,1479,1482,1485,1488,1490,1492],{"class":177,"line":203},[175,1476,297],{"class":222},[175,1478,300],{"class":185},[175,1480,1481],{"class":222},"\"zone_id\"",[175,1483,1484],{"class":185},"], ",[175,1486,1487],{"class":222},"\"OVERLAY_FIELDS\"",[175,1489,300],{"class":185},[175,1491,1481],{"class":222},[175,1493,312],{"class":185},[175,1495,1496,1498,1500,1503,1505,1507,1509,1511,1513,1515],{"class":177,"line":210},[175,1497,336],{"class":222},[175,1499,339],{"class":185},[175,1501,1502],{"class":222},"\"other_\"",[175,1504,306],{"class":185},[175,1506,367],{"class":222},[175,1508,339],{"class":185},[175,1510,1002],{"class":222},[175,1512,364],{"class":185},[175,1514,367],{"class":222},[175,1516,232],{"class":185},[175,1518,1519,1522,1524,1527,1529,1531,1533,1536,1538,1540,1542,1544,1547,1549,1552],{"class":177,"line":235},[175,1520,1521],{"class":185},"real ",[175,1523,216],{"class":181},[175,1525,1526],{"class":185}," [f ",[175,1528,619],{"class":181},[175,1530,622],{"class":185},[175,1532,625],{"class":181},[175,1534,1535],{"class":185}," self_overlaps.getFeatures() ",[175,1537,793],{"class":181},[175,1539,833],{"class":185},[175,1541,1481],{"class":222},[175,1543,616],{"class":185},[175,1545,1546],{"class":181},"!=",[175,1548,833],{"class":185},[175,1550,1551],{"class":222},"\"other_zone_id\"",[175,1553,1554],{"class":185},"]]\n",[175,1556,1557,1559,1561,1563,1566,1569,1572,1574,1577],{"class":177,"line":254},[175,1558,380],{"class":229},[175,1560,662],{"class":185},[175,1562,865],{"class":229},[175,1564,1565],{"class":185},"(real) ",[175,1567,1568],{"class":181},"\u002F\u002F",[175,1570,1571],{"class":229}," 2",[175,1573,306],{"class":185},[175,1575,1576],{"class":222},"\"overlapping pairs of soil zones\"",[175,1578,698],{"class":185},[14,1580,1581,1583,1584,1588],{},[399,1582,401],{}," Every feature intersects itself completely, so those pieces are dropped by comparing ids; each genuine overlap appears twice, once from each side, hence the halving. This is a quick check rather than a full topology audit — ",[21,1585,1587],{"href":1586},"\u002Fspatial-data-processing-automation\u002Fdata-quality-and-topology-validation\u002Ffind-gaps-and-overlaps-between-polygons-pyqgis\u002F","finding gaps and overlaps"," handles tolerances and reporting properly.",[136,1590,1592],{"id":1591},"qgis-version-compatibility","QGIS version compatibility",[14,1594,1595,1597,1598,1600,1601,1604,1605,1065],{},[27,1596,29],{}," with field selection and prefix works on QGIS 3.34 LTR, 3.40 LTR and QGIS 4. Since 3.20 it can use multiple overlay layers through ",[27,1599,1079],{},". On QGIS 4, ",[27,1602,1603],{},"QgsFeatureRequest.GeometryAbortOnInvalid"," is ",[27,1606,1607],{},"Qgis.InvalidGeometryCheck.AbortOnInvalid",[136,1609,1611],{"id":1610},"troubleshooting","Troubleshooting",[141,1613,1614,1620,1626,1632],{},[144,1615,1616,1619],{},[399,1617,1618],{},"Totals are far too large."," Area fields were copied from the inputs; recompute on the pieces.",[144,1621,1622,1625],{},[399,1623,1624],{},"The output is empty."," The layers do not overlap, often because one is in a different CRS with a wrong definition.",[144,1627,1628,1631],{},[399,1629,1630],{},"Thousands of tiny pieces."," Boundaries do not coincide; filter slivers or snap first.",[144,1633,1634,1637],{},[399,1635,1636],{},"The run stops with a geometry error."," Fix invalid geometries before overlaying.",[136,1639,1641],{"id":1640},"conclusion","Conclusion",[14,1643,1644],{},"Intersect with explicit field lists and a prefix to avoid name clashes, recompute area or length on every piece, filter slivers with area and thinness thresholds tied to accuracy, fail fast on invalid geometry, and group the pieces into the summary the question asks for.",[136,1646,1648],{"id":1647},"frequently-asked-questions","Frequently Asked Questions",[14,1650,1651,1654],{},[399,1652,1653],{},"What is the difference between intersection and clip?","\nClip keeps only the input's attributes and cuts it by the overlay's outline; intersection keeps attributes from both and splits by each overlay feature.",[14,1656,1657,1660,1661,1665],{},[399,1658,1659],{},"Can I intersect points with polygons?","\nYes — the output is the points inside polygons, with polygon attributes. A ",[21,1662,1664],{"href":1663},"\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Fspatial-join-points-in-polygons-pyqgis\u002F","spatial join"," is usually simpler.",[14,1667,1668,1671],{},[399,1669,1670],{},"Is the result different if I swap input and overlay?","\nGeometry is the same; field order and the output geometry type follow the input.",[14,1673,1674,1677],{},[399,1675,1676],{},"Why does the output have more features than either input?","\nEach input feature is split once per overlay feature it overlaps, so a field crossing four soil zones becomes four pieces. Feature counts grow with how finely the two layers cut each other.",[14,1679,1680,1683,1684,1065],{},[399,1681,1682],{},"How do I keep the parts outside the overlay too?","\nUse union, covered in ",[21,1685,1687],{"href":1686},"\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Funion-overlay-layers-pyqgis\u002F","union overlay of layers",[136,1689,1691],{"id":1690},"related","Related",[141,1693,1694,1699,1705,1710,1716],{},[144,1695,1696,1698],{},[21,1697,24],{"href":23}," — the guide this recipe belongs to",[144,1700,1701],{},[21,1702,1704],{"href":1703},"\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Ferase-features-with-difference-pyqgis\u002F","Erase Features with Difference in PyQGIS",[144,1706,1707],{},[21,1708,1709],{"href":1686},"Union Overlay of Layers in PyQGIS",[144,1711,1712],{},[21,1713,1715],{"href":1714},"\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Fclip-vector-layer-pyqgis\u002F","Clip a Vector Layer in PyQGIS",[144,1717,1718],{},[21,1719,1721],{"href":1720},"\u002Fspatial-data-processing-automation\u002Fgeometry-operations-and-predicates\u002Fcheck-geometry-intersects-pyqgis\u002F","Check Whether Geometries Intersect in PyQGIS",[1723,1724,1725],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}",{"title":171,"searchDepth":189,"depth":189,"links":1727},[1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740],{"id":138,"depth":189,"text":139},{"id":160,"depth":189,"text":161},{"id":421,"depth":189,"text":422},{"id":718,"depth":189,"text":719},{"id":915,"depth":189,"text":916},{"id":1068,"depth":189,"text":1069},{"id":1198,"depth":189,"text":1199},{"id":1440,"depth":189,"text":1441},{"id":1591,"depth":189,"text":1592},{"id":1610,"depth":189,"text":1611},{"id":1640,"depth":189,"text":1641},{"id":1647,"depth":189,"text":1648},{"id":1690,"depth":189,"text":1691},"Overlay two layers with native:intersection to get the pieces where they overlap with attributes from both — choosing which fields to keep, recomputing areas and lengths after the cut, avoiding slivers, handling invalid input, and summarising the result.","md",{"slug":1744,"type":1745,"breadcrumb":1746,"datePublished":1747,"dateModified":1747},"intersect-two-vector-layers-pyqgis","article","Intersect Two Vector Layers","2026-10-02","\u002Fspatial-data-processing-automation\u002Fvector-data-manipulation\u002Fintersect-two-vector-layers-pyqgis",{"title":5,"description":1741},"spatial-data-processing-automation\u002Fvector-data-manipulation\u002Fintersect-two-vector-layers-pyqgis\u002Findex","pb-LXKGv634_C8M2oUsbmRH5TB6jG-Xw8L3KLT5kmzk",1790966265899]