|
| 1 | +--- |
| 2 | +title: "Introduction to Raster Data" |
| 3 | +teaching: 15 |
| 4 | +exercises: 5 |
| 5 | +--- |
| 6 | + |
| 7 | +:::questions |
| 8 | +- What format should I use to represent my data? |
| 9 | +- What are the main data types used for representing geospatial data? |
| 10 | +- What are the main attributes of raster data? |
| 11 | +::: |
| 12 | + |
| 13 | +:::objectives |
| 14 | +- Describe the difference between raster and vector data. |
| 15 | +- Describe the strengths and weaknesses of storing data in raster format. |
| 16 | +- Distinguish between continuous and categorical raster data and identify types of datasets that would be stored in each format. |
| 17 | +::: |
| 18 | + |
| 19 | +## Introduction |
| 20 | + |
| 21 | +This episode introduces the two primary types of geospatial |
| 22 | +data: rasters and vectors. After briefly introducing these |
| 23 | +data types, this episode focuses on raster data, describing |
| 24 | +some major features and types of raster data. |
| 25 | + |
| 26 | +## Data Structures: Raster and Vector |
| 27 | + |
| 28 | +The two primary types of geospatial data are raster |
| 29 | +and vector data. Raster data is stored as a grid of values which are rendered on a |
| 30 | +map as pixels. Each pixel value represents an area on the Earth's surface. Vector data structures represent specific features on the |
| 31 | +Earth's surface, and |
| 32 | +assign attributes to those features. Vector data structures |
| 33 | +will be discussed in more detail in [the next episode](02-intro-vector-data.md). |
| 34 | + |
| 35 | +This workshop will focus on how to work with both raster and vector |
| 36 | +data sets, therefore it is essential that we understand the |
| 37 | +basic structures of these types of data and the types of data |
| 38 | +that they can be used to represent. |
| 39 | + |
| 40 | +### About Raster Data |
| 41 | + |
| 42 | +Raster data is any pixelated (or gridded) data where each pixel is associated |
| 43 | +with a specific geographic location. The value of a pixel can be |
| 44 | +continuous (e.g. elevation) or categorical (e.g. land use). If this sounds |
| 45 | +familiar, it is because this data structure is very common: it's how |
| 46 | +we represent any digital image. A geospatial raster is only different |
| 47 | +from a digital photo in that it is accompanied by spatial information |
| 48 | +that connects the data to a particular location. This includes the |
| 49 | +raster's extent and cell size, the number of rows and columns, and |
| 50 | +its coordinate reference system (or CRS). |
| 51 | + |
| 52 | +{alt="raster concept"} |
| 53 | + |
| 54 | +Some examples of continuous rasters include: |
| 55 | + |
| 56 | +1. Precipitation maps. |
| 57 | +2. Maps of tree height derived from LiDAR data. |
| 58 | +3. Elevation values for a region. |
| 59 | + |
| 60 | +A map of elevation for Harvard Forest derived from the [NEON AOP LiDAR sensor](https://www.neonscience.org/data-collection/airborne-remote-sensing) |
| 61 | +is below. Elevation is represented as a continuous numeric variable in this map. The legend |
| 62 | +shows the continuous range of values in the data from around 300 to 420 meters. |
| 63 | + |
| 64 | +{alt="elevation Harvard forest"} |
| 65 | + |
| 66 | +Some rasters contain categorical data where each pixel represents a discrete |
| 67 | +class such as a landcover type (e.g., "forest" or "grassland") rather than a |
| 68 | +continuous value such as elevation or temperature. Some examples of classified |
| 69 | +maps include: |
| 70 | + |
| 71 | +1. Landcover / land-use maps. |
| 72 | +2. Tree height maps classified as short, medium, and tall trees. |
| 73 | +3. Elevation maps classified as low, medium, and high elevation. |
| 74 | + |
| 75 | +{alt="USA landcover classification"} |
| 76 | + |
| 77 | +The map above shows the contiguous United States with landcover as categorical |
| 78 | +data. Each color is a different landcover category. (Source: Homer, C.G., et |
| 79 | +al., 2015, Completion of the 2011 National Land Cover Database for the |
| 80 | +conterminous United States-Representing a decade of land cover change |
| 81 | +information. Photogrammetric Engineering and Remote Sensing, v. 81, no. 5, p. |
| 82 | +345-354) |
| 83 | + |
| 84 | +:::challenge |
| 85 | +## Advantages and Disadvantages |
| 86 | + |
| 87 | +With your neighbor, brainstorm potential advantages and |
| 88 | +disadvantages of storing data in raster format. Add your |
| 89 | +ideas to the Etherpad. The Instructor will discuss and |
| 90 | +add any points that weren't brought up in the small group |
| 91 | +discussions. |
| 92 | + |
| 93 | +::::solution |
| 94 | +## Solution |
| 95 | + |
| 96 | +Raster data has some important advantages: |
| 97 | + |
| 98 | +* representation of continuous surfaces |
| 99 | +* potentially very high levels of detail |
| 100 | +* data is 'unweighted' across its extent - the geometry doesn't |
| 101 | +implicitly highlight features |
| 102 | +* cell-by-cell calculations can be very fast and efficient |
| 103 | + |
| 104 | +The downsides of raster data are: |
| 105 | + |
| 106 | +* very large file sizes as cell size gets smaller |
| 107 | +* currently popular formats don't embed metadata well (more on this later!) |
| 108 | +* can be difficult to represent complex information |
| 109 | +:::: |
| 110 | +::: |
| 111 | + |
| 112 | +### Important Attributes of Raster Data |
| 113 | + |
| 114 | +#### Extent |
| 115 | + |
| 116 | +The spatial extent is the geographic area that the raster data covers. |
| 117 | +The spatial extent of an object represents the geographic edge or |
| 118 | +location that is the furthest north, south, east and west. In other words, extent |
| 119 | +represents the overall geographic coverage of the spatial object. |
| 120 | + |
| 121 | +{alt="spatial extent objects"} |
| 122 | + |
| 123 | +:::challenge |
| 124 | +## Extent Challenge |
| 125 | + |
| 126 | +In the image above, the dashed boxes around each set of objects |
| 127 | +seems to imply that the three objects have the same extent. Is this |
| 128 | +accurate? If not, which object(s) have a different extent? |
| 129 | + |
| 130 | +::::solution |
| 131 | +## Solution |
| 132 | + |
| 133 | +The lines and polygon objects have the same extent. The extent for |
| 134 | +the points object is smaller in the vertical direction than the |
| 135 | +other two because there are no points on the line at y = 8. |
| 136 | +:::: |
| 137 | +::: |
| 138 | + |
| 139 | +#### Resolution |
| 140 | + |
| 141 | +A resolution of a raster represents the area on the ground that each |
| 142 | +pixel of the raster covers. The image below illustrates the effect |
| 143 | +of changes in resolution. |
| 144 | + |
| 145 | +{alt="resolution image"} |
| 146 | + |
| 147 | +### Raster Data Format for this Workshop |
| 148 | + |
| 149 | +Raster data can come in many different formats. For this workshop, we will use |
| 150 | +the GeoTIFF format which has the extension `.tif`. A `.tif` file stores metadata |
| 151 | +or attributes about the file as embedded `tif tags`. For instance, your camera |
| 152 | +might store a tag that describes the make and model of the camera or the date |
| 153 | +the photo was taken when it saves a `.tif`. A GeoTIFF is a standard `.tif` image |
| 154 | +format with additional spatial (georeferencing) information embedded in the file |
| 155 | +as tags. These tags should include the following raster metadata: |
| 156 | + |
| 157 | +1. Extent |
| 158 | +2. Resolution |
| 159 | +3. Coordinate Reference System (CRS) - we will introduce this concept in [a later episode](03-crs.md) |
| 160 | +4. Values that represent missing data (`NoDataValue`) - we will introduce this |
| 161 | + concept in [a later episode](06-raster-intro.md). |
| 162 | + |
| 163 | +We will discuss these attributes in more detail in [a later episode](06-raster-intro.md). |
| 164 | +In that episode, we will also learn how to use Python to extract raster attributes |
| 165 | +from a GeoTIFF file. |
| 166 | + |
| 167 | +:::callout |
| 168 | +## More Resources on the `.tif` format |
| 169 | + |
| 170 | +* [GeoTIFF on Wikipedia](https://en.wikipedia.org/wiki/GeoTIFF) |
| 171 | +* [OSGEO TIFF documentation](https://trac.osgeo.org/geotiff/) |
| 172 | +::: |
| 173 | + |
| 174 | +### Multi-band Raster Data |
| 175 | + |
| 176 | +A raster can contain one or more bands. One type of multi-band raster |
| 177 | +dataset that is familiar to many of us is a color |
| 178 | +image. A basic color image consists of three bands: red, green, and blue. |
| 179 | +Each |
| 180 | +band represents light reflected from the red, green or blue portions of |
| 181 | +the |
| 182 | +electromagnetic spectrum. The pixel brightness for each band, when |
| 183 | +composited |
| 184 | +creates the colors that we see in an image. |
| 185 | + |
| 186 | +{alt="multi-band raster"} |
| 187 | + |
| 188 | +We can plot each band of a multi-band image individually. |
| 189 | + |
| 190 | +Or we can composite all three bands together to make a color image. |
| 191 | + |
| 192 | +In a multi-band dataset, the rasters will always have the same extent, |
| 193 | +resolution, and CRS. |
| 194 | + |
| 195 | +:::callout |
| 196 | +## Other Types of Multi-band Raster Data |
| 197 | + |
| 198 | +Multi-band raster data might also contain: |
| 199 | +1. **Time series:** the same variable, over the same area, over time. |
| 200 | +2. **Multi or hyperspectral imagery:** image rasters that have 4 or |
| 201 | +more (multi-spectral) or more than 10-15 (hyperspectral) bands. We |
| 202 | +won't be working with this type of data in this workshop, but you can |
| 203 | +check out the NEON Data Skills [Imaging Spectroscopy HDF5 in R](https://www.neonscience.org/hsi-hdf5-r) |
| 204 | +tutorial if you're interested in working with hyperspectral data cubes. |
| 205 | +::: |
| 206 | + |
| 207 | +:::keypoints |
| 208 | +- Raster data is pixelated data where each pixel is associated with a specific location. |
| 209 | +- Raster data always has an extent and a resolution. |
| 210 | +- The extent is the geographical area covered by a raster. |
| 211 | +- The resolution is the area covered by each pixel of a raster. |
| 212 | +::: |
0 commit comments