CEE 8813 · GIS Lecture 4 · Spatial selection and spatial join

Spatial Join Lab

Select By Location picks features by where they are. Spatial Join goes one step further and copies attributes, or counts, from one layer onto another by location. Run both tools on the lab's crash, county and curve data, and watch how the target layer, the join layer and the match option change the answer.

Lab map · metro Atlanta

Select Layer By Location

ArcGIS Pro: Map tab ▸ Select By Location. ArcMap: Selection menu ▸ Select By Location.
Selected features
ArcMap shows this as a check box. ArcGIS Pro does it automatically whenever the selecting layer has a selection.
Selected0
Change0
Fatal or serious0

What you are seeing

Spatial Join output

The six spatial-join questions

Slide 6 (after Price) sorts spatial joins by two questions. Is the answer simple (each record gets one set of attributes) or summarised (a count or a sum)? Is the match made by being inside, or by distance? Here are the same questions asked of the lab data. Click a card to set up the Spatial Join tool; each answer is computed from the data.

Data check: the county in the report vs the county on the map

Every crash report names a county (the field Area__Coun). Case (a) finds the county from the crash's coordinates instead. The two should agree. Where they do not, find out why before you trust a count per county.

Agree0one polygon, same county as the report
In two polygons0Join_Count 2 in case (a)
Different county0one polygon, not the reported county
No location0coordinates −1, −1

Try this in class

  1. Start where slide 3 starts. Fulton is selected, and Select By Location (Crashes, Intersect, Counties) has selected 128 crashes. Press “Clear county selection” and Run again. With no county selected, ArcGIS uses all 159 counties, and 477 of the 480 crashes are selected.
  2. Click Fulton again, Shift-click DeKalb, set Selection Type to “Add to the current selection” and Run. Then select Fulton alone, choose “Within a distance” with 5,280 ft (one mile) and see how many crashes sit just outside the county line.
  3. Set Selecting Features to Curves, “Within a distance”, 150 ft. These are the lab's curve-related crashes. Now switch the relationship to Intersect and explain why the count collapses.
  4. Click case (a), then case (b). Same two layers, swapped. Compare the number of output rows (480 against 159) and what Join_Count means in each.
  5. In case (b), change the merge rule from Sum to First and look at F__of_Fata for Fulton. Then switch Join Operation to one to many and watch the row count.
  6. Click case (c), then type 150 in Search Radius. Most crashes drop to Join_Count 0. Compare with case (e). Then open case (d): why do a few curves at the edge of District 7 collect so many crashes?

Pitfalls students hit

  • Target first. The target layer decides the rows. Counties ← Crashes gives 159 rows; Crashes ← Counties gives 480.
  • Closest always finds something. Without a search radius, a crash in Savannah still gets a District 7 curve as its closest, more than 180 miles away.
  • Planar or geodesic. Distances here are planar, in US feet, in a projected coordinate system like State Plane Georgia West. If your layers are in a GCS (degrees), project them first or use the geodesic match options. Always check the unit next to the search distance: 150 should read 150 feet.
  • Select the county first. If nothing is selected in Counties, Select By Location uses every county.
  • Merge rules. ArcGIS Pro's default merge rule is First. To total the fatalities in each county, set F__of_Fata to Sum in the field map.
  • One to one keeps one row per target. Join_Count tells you how many features matched; the attributes come from the first one.

Back to Lecture 4: slides 3 to 6

The lecture uses ArcMap screenshots. The same tools sit in ArcGIS Pro under slightly different names.

Select By LocationSlide 3 · select collisions in Fulton County

Select Fulton in GA_Counties first, then select the collisions that intersect it. Input Features = Collisions, Relationship = Intersect, Selecting Features = GA_Counties, using the selected feature only.

ArcGIS Pro: Map tab ▸ Select By Location (the Select Layer By Location tool). ArcMap's methods such as “intersect the source layer feature” and “are within the source layer feature” correspond to Pro's Intersect and Within.

Spatial JoinSlides 4–5 · collisions per county, county of each collision

Slide 4 counts collisions in each county. The counties are the target, so the output has one row per county and Join_Count holds the count. Slide 5 asks which county each collision is in. The collisions are the target, and each one receives the county's attributes.

ArcGIS Pro: Analysis tab ▸ Tools ▸ Spatial Join. Defaults: Join one to one, Keep All Target Features on, match option Intersect, merge rule First.

Six kinds of spatial joinSlide 6 · simple or summarised, inside or distance

Price's examples map onto the lab data. Which county is each school in = case (a). How many schools in each county = case (b). Which attraction is closest to each hotel, and how far = case (c). How many attractions are closest to each hotel = case (d), with crashes in the role of the attractions and curves in the role of the hotels.

ArcMap's join dialog had a one-step option for case (d). In ArcGIS Pro, run Spatial Join with Closest (or the Near tool) and then Summary Statistics on the joined ID.

Buffer, then select and joinSlides 7–11 · the in-class exercise

The exercise buffers the District 7 curves by 150 ft (round ends), selects the crashes inside the buffer, and joins curve attributes to those crashes. Within a distance of 150 ft gives the same crashes without making a buffer layer.

The band drawn on the map for “Within a distance” is exactly that 150 ft round buffer, dissolved.

Read the tool dialogs the same way every time. The target layer is the one whose rows you get back. The join layer is the one whose attributes, or count, are copied across. The match option is the spatial rule that decides which join features belong to each target.