Spatial Joins Made Easy
We cover a quick and easy way to do temporary spatial joins
When we opened up the mail bag here at GIS Central recently, out popped a request from a colleague: “Do we have a mapping table of LAWA monitoring site names to the regional council site names?” Perhaps I should decode this a bit before we get to a solution.
LAWA is Land, Air, Water Aoteroa, a consortium of regional councils, DOC, MFE and several others (Ed.: Egads! Government working together…?!?) that aims to provide public access to monitoring data on our natural resources.
When you want to find out which beaches have the best water quality for swimming, this is probably where you’ll end up:
My colleague had a layer of these water quality monitoring sites but the attributes didn’t include which region each site was in. Could GIS help? Absolutely. And in getting to a solution we discovered a nice quick way to do some temporary spatial joins.
So let’s start with the data. The monitoring sites were in the form of a .gpkg file. The is a geopackage, a format I’ve not come across much but is basically an open-source data container for sharing spatial data. It’s a nice compact way to share data as email attachments, for example. Pro can read these like many of the data formats available, so it was easily added to a map:
You can see that the attribute table is pretty simple – the main information available is the “lawaid”, a unique identifier for each of the 1,013 sites. What’s missing is information on what region each site is in. Let’s address that by adding a layer of the regional council boundaries (J:\Data\Administrative_Boundaries\regional_council_2018_clipped.shp):
Also a relatively simple layer, the most useful thing being the REGC2018_1 attribute which has the name of each region. At this point, these are two separate layers on the map and I need to come up with some way to bring all the attributes together in to one layer, ideally so that I have a single layer with regional council names attached to each site. I can’t do a table join as there’s no common attribute between the two layers so I need to use their locations do to the join. This suggests that I could use a spatial join tool, such as Intersect, Identity or Union. These tools create a new layer that combines the input layers based on their locations.
In this latest version of Pro (3.0.3 as of this writing) I discovered a handy new addition that could save me a few steps. In the Contents pane, clicking on the layer name gets you a context menu – we’re looking for Joins and Relates and what’s under there:
Those of you used to doing Table Joins will be familiar with this menu – very handy. The new addition here is “Add Spatial Join”, so let’s check that out.
The Target Features are the LAWA sites while the Join Features come from the regional council layer. Intersect is a good option for the match but be aware that there are lots of others. When I click OK, the attribute values from the the regional council layer that intersects with the LAWA point layer are added in the table:
Nifty, now with this layer we know the region that each site is in.
One important note is that this join is temporary. If I add this layer to another map, or send it to someone else, the regional council data won’t be a part of it. To make it permanent I would need to make a new copy of the data (right-click the layer name > Data > Export Features).
My next step was to export this table as a CSV file that my colleague could use. Job done.
Most of the time, GIS only gives me trouble and heartache (I exaggerate…slightly) so it was nice that I could help out a colleague and do it quite easily. And once again, we get to see the value of spatial joins. This won’t be the last time.