Spatial Join is a classic GIS problem - transferring attributes from one layer to another based on their spatial relationship. In QGIS, this functionality is available through the Join Attributes by Location tool.
We will use 2 layers - A shapefile of burough boundaries of New York city and another shapefile of nursing home locations in New York city. We will use spatial join technique to find the total nursing home capacity for each of the buroughs.
NYC Open Data Portal is an excellent source of free data for New York city.
For convenience, you may directly download a copy of the datasets from the links below:
nybb_12c.zip and select Open.
nybb.shp and click OK.
OEM_NursingHomes_001.zip
and load the OEM_NursingHomes_001.shp layer. Once both the layers are
loaded, right-click on the OEM_NursingHomes_001 layer and select
Open Attribute Table.
nybb layer. The
Join vector layer will be the nursing homes
OEM_NursingHomes_001 layer. As we want to sum the capacity of nursing
homes, select Take summary of intersecting features and choose
Sum. Name the output file as nyc_borough_join.shp. In the
Output table select Keep all records`.
nyc_borough_join would have the
features from nybb layer along with spatially joined attributes from
OEM_NursingHomes_001 layer. Right-click on the layer and select
Open Attribute Table.
Control-A to select all columns in the Delete
Attributes dialog. Next hold the Control key and de-select the
columns you want to keep. Click OK.
This work is licensed under a Creative Commons Attribution 4.0 International License