Spatial Join

A common GIS task is to join the attributes from one spatial data layer to another. In this example we will join the attribute table from a polygon layer to a points layer, based on which polygon contains the points.

Prepare Target Points Layer
  • For this exercise, we'll use a set of points generated in Google Maps, showing some interesting sites in Taiwan
  • Add Vector Data, set UTF-8 encoding, and browse to china/taiwan_points.kml
  • Save As filename "TW_pts_big5" as format = ESRI Shapefile and encoding = BIG5 (we want to join BIG5 attribute table to this target layer, so SET CORRECT ENCODING FOR THE DATA THAT WILL BE JOINED)
  • Add the newly created TW_pts_big5 layer and remove the imported taiwan_points KML import layer.
  • Target Points layer should be ready for the join

Prepare Join Layer
  • Now we want to Add Vector Layer and browse to the TW_POP layer, encoding = big5
  • Open the Attribute Table to make sure the encoding looks okay. If it looks fine, close the attribute table.
  • Go to menu VECTOR | DATA MANAGEMENT TOOLS | JOIN ATTRIBUTES BY LOCATION

Run the Join
  • Set the TARGET LAYER = TW_points_big5, set the JOIN LAYER = TW_POP
  • Click on the OUTPUT SHAPEFILE BROWSE button to set output path, filename, and encoding = big5, then click SAVE
  • Click OK and you will be prompted to add the new join shapefile to the TOC (table of contents), click YES
  • Open the Attribute Table of the new join layer. Each point feature now includes the attributes from the JOIN layer, having done a SPATIAL JOIN on the polygon that the point was located in.