# How do I find the percent overlap between two shapefiles in QGIS?

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
....                 ....
``````

• 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:

`area(\$geometry)`

• 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"`