I have two different shapefiles (first and second). I want to calculate how much overlap there is between the liquefaction zones in the second shapefile and each of the neighborhoods in the first.

I'm using QGIS. My ideal output would be something like:

nhood    percent in liquefaction
Glen Park            .75
Financial District   .60
Tenderloin           .32
....                 ....
  • 2
    First make sure that both shapefiles are in a suitable projected coordinate system, calculate the area before intersection gis.stackexchange.com/questions/23355/…, intersect the two shapefiles gis.stackexchange.com/questions/251501/intersect-polygons and then calculate the area after intersection, percent is area after / area before. Commented Feb 22, 2019 at 0:47
  • I received a Please fix the geometry or change the Processing setting to the 'ignore invalid input features' option error message when I tried to union
    – Sebastian
    Commented Feb 22, 2019 at 1:02
  • 1
    You've got at least one invalid geometry, have a read of gis.stackexchange.com/questions/112687/… and see if that helps or read gis.stackexchange.com/questions/289056/… about the ignoring invalid geometries (which I don't suggest as the geometries skipped may be a major component). Commented Feb 22, 2019 at 1:05
  • I have a reference file that has values for some of the neighborhoods. I chose to ignore the invalid geometries and the numbers match up almost 1:1.
    – Sebastian
    Commented Feb 22, 2019 at 1:17
  • 1
    Liquifaction id = 92 has not a valid geometry (self intersection). Fix it. Commented Feb 22, 2019 at 1:33

1 Answer 1

  • Check that there are not invalid geometries

My way to do that, is Creating a Virtual Layer, with the SQL statement:

SELECT geometry, other_column_names 
FROM layer_name 
WHERE NOT ST_IsValid(geometry) 

If the layer created has a geometry, identify it and fix the corresponding geometry in the original layer with the Vertex Tool. Sometimes the problem is not easy to fix, but that is another problem.

  • Reproject both layers to a convenient CRS

I am used to reproject to transverse Mercator, tangential to a point of the work area, because I need the angles to be preserved. But you can use another CRS. I create a custom CRS for each project, in this project it would be:

+proj=tmerc +lat_0=37.77 +lon_0=-122.43 +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs

  • Add a new decimal number (real) field (named e.g. "area") to the neighborhoods layer, and populate it with the planimetric area of the geometries:


  • Perform the Difference between the neighborhoods and the liquefaction zones:

The ouptut is a new Difference layer, with the neighborhoods that are not covered by liquefaction zones. In this case, I use the difference because it returns just one feature for each feature of the input table, with its attributes. To calculate the precent covered, then I calculate 100 - the percent not covered. (If you need the polygons of the covered areas, you can make a new difference between the neighborhoods and this layer.)

  • Add a new decimal number (real) field to the Difference layer, and populate it with the percent in liquefaction:

100 - area($geometry) * 100 / "area"

If you want the coefficient instead:

1 - area($geometry) / "area"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.