spatial joins in QGIS 🧩
in the past I have done a lot of work in the esri ecosystem. Often I have found myself challenged when I come to QGIS and am looking for a tool or option but the names are not the same.
I encountered an issue like this last week as I worked preparing data for a consulting client in Nashville who was looking to isolate existing point data by location specific factors designated in their project shapefiles.
A quick spatial join right? So long as you remember it.
For an example, I first pulled in the city of San Antonio Texas fire department district map. If you want to work with the data, you can find it here
Next I downloaded location point data for the city of San Antonio emergency facilities. A factor to consider later is that this contained locations for fire and police. In my join, I just want to join fire stations to fire districts.
Get only fire stations, Select by attribute and in my case, the field I'm selecting by is AgencyType:FIRE. This lets me select only this data to work with. I can either create a new file based on this or I can simply navigate to the the spatial join tool and select the option for
Going to the vector menu -> Data Management Tools -> Join Attributes by Location
Then in the tool options menu, our base layer is the public safety facilities point file, join layer is the SAFD area polygon file. Notice we have checked the option for Selected Features Only. The spatial join is only run on FIRE fields in the base layer.
Options for more precise joins exist in this menu. Read the documentation listed below for a more in depth look at what you can do with these options. For today, I went ahead and selected points contained within the fire area geometry and also selected the fire district ID field so the final result contains this join.
The final result shows the location of fire stations with joined fire stations which now contain district name info from the fire area layer. All in all, a simple yet powerful tool. The next step is scripting a process like this to minimize time from data input to final layer.