Get startedGet started for free

Common types of spatial data

1. Common types of spatial data

The house sales data you have been working with is an example of point data.

2. Types of spatial data

With point data, our locations are points, in our case, a house location, and each point has some associated data, in our case, price and house attributes. While point data is common there are some other types of spatial data that you'll commonly come across: line data, polygon data and raster data.

3. Types of spatial data

When the data is associated with a collection of points in a line, we call it line data. To describe the line, we need multiple points, and we assume they are connected with straight lines. The data isn't associated with any single point, but with the whole collection of points. For example, our lines might describe streams, and for each stream we know its name and length.

4. Types of spatial data

Polygon data occurs when the data is associated with an area. To describe the area we take a collection of points and join them with lines to enclose a polygon. The data is associated with the enclosed area. For example, a farmer might have polygons that describe his fields. Each polygon might have a name, an area and a crop.

5. Types of spatial data

Finally, raster data, also called grid data, is a little different. A regular grid is specified by an origin and steps in the x and y axes. Data is associated with every cell in the grid. This commonly occurs in remote sensing, where a satellite is used to image the earth. For example, for each cell in our grid, we might have the type of vegetation it contains, its elevation and slope. To get a feel for these other types of spatial data, in the final exercises for the chapter, you'll work with some polygon and raster data related to the house sales data.

6. House prices by ward

In Corvallis, we have wards, areas that define roughly equal numbers of people that are each represented by a Councilor on the city council. These wards are described by polygons, and provide a useful geographical breakdown of the city, to provide a higher level summary of house sales. The ward_sales data frame, describes the ward polygons and some summaries at the ward level, like average sales price and number of sales. Polygons are described by a collection of points, in this data frame each point is a row. Since it takes many rows to describe the shape of a single ward, you can see the summary data is repeated many times. The columns, group and order, are there to help with the two tricky parts of drawing polygons.

7. Drawing polygons is tricky

The first tricky part of drawing polygons is that order matters. The same set of points, joined in two different orders, will result in two different polygons.

8. Drawing polygons is tricky

The second tricky part, a single area, might need multiple polygons to describe it. For example, one of our wards might have two pieces divided by a river, or a hole like a lake, that is excluded.

9. Predicted house prices

As an example of raster data, you'll work with the output from a model, that predicts the price of a 3-bedroom, 2 full bathroom, 1400 square foot dwelling in average condition. This will help us explore which areas are more expensive than others for the same house. In the preds data frame each row is a cell in a spatial grid over Corvallis. The lon and lat columns specify the coordinates at the center of the cell and the predicted_price columns the sales price predicted at this location.

10. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.