2

For my final project in a GIS-related course, I have chosen to look at the historical data of earthquakes in California to try and make a kind of risk assessment based on cities and their population density. For this, I have created a buffer around each earthquake, where the radius is dependent on the magnitude. The resulting circles are then areas of effect. These two layers look like the following: enter image description here

What I would like to do is then, for each city polygon, count how many times a buffer intercepts with it, to get a number telling how many times, an earthquake has affected the area. I have been looking a bit into the "num_geometries" function of the field calculator, but am unaware whether this would be an ideal route to go.

Edit: The two layers with their unique fields. The city layer: enter image description here

The earthquake layer: enter image description here enter image description here

2
  • Have a look here: gis.stackexchange.com/a/395823/88814 – Babel May 8 at 9:03
  • Intersect the 2 layers using the Vector Geoprocessing Tools. Put the cities layer first, then the earthquake circles. The resulting table has the IDs of both where they intersect. You can do anSQL query on this, or add a field to the intersection layer like COUNT(ID,ID), which will have the number of intersections for each feature. – wingnut May 8 at 9:20
3

You can use a simple query in DB Manager, like:

SELECT bldg.* , count(quakes.id) FROM "New Scratch Layer" AS bldg, Buffered AS quakes WHERE st_intersects(quakes.geometry,bldg.geometry) GROUP BY bldg.ID

Then Load it as a layer in the DB Manager (at the bottom) and style it to show by number of quakes. The attribute table will have the counts.

INPUT

enter image description here

Query

enter image description here

OUTPUT

enter image description here

7
  • Thanks for the answer. It seems to be what i am somewhat looking for (i have some more analysis to do, but i think i can build upon this). However my lecturer has not gone into depth with the DB manager at all, and i have never worked with SQL before, so i am a bit confused about how to exactly execute the query you have written. In my project i have all of the populated areas as a layer named "CA_pop" and my buffered circles layer simple named as "Buffered". Furthermore, none of the layers actually have a ID column. The city layer has a unique str NAME, and the buffered a unique str ID. – Kasper Maegaard Borby-Nielsen May 8 at 10:47
  • SQL is an acquired taste :-) - Yes, replace the layer names. So in your case it's SELECT CA_pop.* , count(Buffered.id) FROM CA_pop , Buffered WHERE st_intersects(Buffered.geometry, CA_pop.geometry) GROUP BY CA_pop.ID. This assumes that Buffered has a unique column called id or ID (change it to a unique column name if not) The query says to intersect the two layers internally and then return ALL columns from CA_pop (including the geometry) and the number of occurrences of Buffered (by counting IDs) in the intersection. You'd need to know a bot of SQL but it's not hard. – wingnut May 8 at 10:53
  • I can see how it works. However my query returns nothing when i execute it. So something seems amiss in what i am doing, but i cannot seem to figure it out unfortunately – Kasper Maegaard Borby-Nielsen May 8 at 12:13
  • what are the unique fields in each layer? – wingnut May 8 at 12:27
  • I have edited the original question, so you can see the different fields of the layers – Kasper Maegaard Borby-Nielsen May 8 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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