Chapter 5 Using R as a GIS

5.2 Spatial Intersection and Clip Operations

The tornado data

Figure 5.1: The tornado data

The tornado data in the defined Area of Interest

Figure 5.2: The tornado data in the defined Area of Interest

5.5 Point-in-polygon and Area calculations

5.5.1 Point-in-polygon

   1    2    3    4    5    6 
  79  341   87 1121 1445  549 

5.5.3 Point and Areas analysis exercise

[1] -0.2038463
The distribution of the model1 residuals , describing the relationship between breaches of the peace and owner occupancy

Figure 5.5: The distribution of the model1 residuals , describing the relationship between breaches of the peace and owner occupancy

The distribution of the model2 residuals, describing the relationship between breaches of the peace with owner occupancy and vacant proprties

Figure 5.6: The distribution of the model2 residuals, describing the relationship between breaches of the peace with owner occupancy and vacant proprties

5.6 Creating distance attributes

5.6.1 Distance analysis / Accessibility exercise

          Black Native American           Asian 
          -35.1           -11.7           -29.8 
          Other 
          256.3 

5.7 Combining spatial datasets and their attributes

The zones and census tracts data before and after intersection

Figure 5.7: The zones and census tracts data before and after intersection

The zones shaded by the number of households after intersection with the census tracts

Figure 5.8: The zones shaded by the number of households after intersection with the census tracts

5.8 Converting between Raster and Vector

5.8.1 Vector to Raster

5.8.2 Converting to sp raster classes

r <- raster(nrow = 60 , ncols = 120, ext = extent(us_states2)) 
r <- rasterize(us_states2 , r, "BLACK") 
Selecting data in a raster object

Figure 5.12: Selecting data in a raster object

5.9 Introduction to Raster Analysis

5.9.3 Other Raster Calculations

A raster analysis of distance to points

Figure 5.17: A raster analysis of distance to points

5.10 Answers to self-test questions

Q1 First, using sf formats:

Second, using sp formats:

Q2

Q3

   (Intercept) notforced.rate 
     5.4667222      0.3789628 
expected(forced rate) =  5.466722 + 0.3789628 * (not forced rate)
expected(forced rate) =  5.243477 + 0.4132951 * (not forced rate)

Q4