Spatial Data and GIS Lessons

Use R, Python and Other Open Tools For GIS

Most scientific data are geographically located and thus have a spatial component. GIS skills are thus important for working with scientific data. R and Python are free and open scientific programming languages that you can use to work with GIS data and do tasks that you may already do with tools like ArcGIS or QGIS.

In the lessons below, learn how to open, manipulate and plot spatial data in the R programming language. Also learn to use tools like Leaflet and ggplot to create custom and interactive maps. Finally learn how to use remote sensing data like Landsat, NAIP and MODIS in R. Come back later this spring for lessons in Python!

How to Download MACA2 Climate Data Using Python

MACA V2 climate data provides but historica and future predictions of climate variables using different models. Learn how to download netcdf 4 format programatically using open source Python and open the data with xarray.

last updated: 19 Nov 2021

Introduction to the CMIP and MACA v2 Climate Data

In this lesson you will learn the basics of what CMIP5 and MACA v 2 data are and how global climate data are downscaled to higher resolutions to support regional analysis.

last updated: 19 Nov 2021

Introduction to the NetCDF4 Hierarchical Data Format

In this lesson you will learn about that netcdf 4 data format which is a format, commonly used to store climate data. In later lessons you will learn how to open climate data using open source Python tools.

last updated: 12 Nov 2020

File Formats Exercise

Complete these exercises to practice the skills you learned in the file formats chapters.

last updated: 11 Sep 2020

Spatial Data Formats for Earth Data Science

Two of the major spatial data formats used in earth data science are vector and raster data. Learn about these two common spatial data formats for earth data science workflows in this chapter.

last updated: 23 Sep 2020

Work with Landsat Remote Sensing Data in Python

Landsat 8 data are downloaded in tif file format. Learn how to open and manipulate Landsat 8 data in Python. Also learn how to create RGB and color infrared Landsat image composites.

last updated: 11 Jun 2021

Calculate Vegetation Indices in Python

A vegetation index is a value that quantifies vegetation health or structure. Learn how to calculate the NDVI and NBR vegetation indices to study vegetation health and wildfire impacts in Python.

last updated: 28 Jan 2021

Customize your Maps in Python using Matplotlib: GIS in Python

When making maps, you often want to create legends, customize colors, adjust zoom levels, or even make interactive maps. Learn how to customize maps created using vector data in Python with matplotlib, geopandas, and folium.

last updated: 21 Jul 2020

How to Dissolve Polygons Using Geopandas: GIS in Python

When you dissolve polygons, you remove the interior boundaries of a set of polygons with the same attribute value and create one new merged or combined polygon for each attribute value. Learn how to dissolve polygons in Python using GeoPandas.

last updated: 28 Jan 2021

GIS in Python: Reproject Vector Data.

Often when spatial data do not line up properly on a plot, it is because they are in different coordinate reference systems (CRS). Learn how to reproject a vector dataset to a different CRS in Python using the to_crs() function from GeoPandas.

last updated: 11 Sep 2020

GIS in Python: Reproject Vector Data.

Often when spatial data do not line up properly on a plot, it is because they are in different coordinate reference systems (CRS). Learn how to reproject a vector dataset to a different CRS in Python using the to_crs() function from GeoPandas.

last updated: 11 Sep 2020

Subtract Raster Data in Python Using Numpy and Rasterio

Sometimes you need to manipulate multiple rasters to create a new raster output data set in Python. Learn how to create a CHM by subtracting an elevation raster dataset from a surface model dataset in Python.

last updated: 04 Sep 2019

Open, Plot and Explore Lidar Data in Raster Format with Python

This lesson introduces the raster geotiff file format - which is often used to store lidar raster data. You will learn the 3 key spatial attributes of a raster dataset including Coordinate reference system, spatial extent and resolution.

last updated: 04 Sep 2019

Learn to Use NAIP Multiband Remote Sensing Images in Python

Learn how to open up a multi-band raster layer or image stored in .tiff format in Python using Rasterio. Learn how to plot histograms of raster values and how to plot 3 band RGB and color infrared or false color images.

last updated: 28 Jan 2021

Customize Map Extents in Python: GIS in Python

When making maps, sometimes you want to zoom in to a specific area in your map. Learn how to adjust the x and y limits of your matplotlib and geopandas map to change the spatial extent that is displayed.

last updated: 21 Jan 2022

Customize Matplotlib Raster Maps in Python

Sometimes you want to customize the colorbar and range of values plotted in a raster map. Learn how to create breaks to plot rasters in Python.

last updated: 21 Jan 2022

Interactive Maps in Python

Folium is a Python package that can be used to create interactive maps in Jupyter Notebook. Learn how to create interactive maps with raster overlays in Python using Folium.

last updated: 21 Jan 2022

Plot Spatial Raster Data in Python.

When plotting rasters, you often want to overlay two rasters, add a legend, or make the raster interactive. Learn how to make a map of raster data that has these attributes using Python.

last updated: 21 Jul 2020

Reproject Raster Data Python

Sometimes you will work with multiple rasters that are not in the same projections, and thus, need to reproject the rasters, so they are in the same coordinate reference system. Learn how to reproject raster data in Python using Rasterio.

last updated: 09 Nov 2020

Crop Spatial Raster Data With a Shapefile in Python

Sometimes a raster dataset covers a larger spatial extent than is needed for a particular purpose. In these cases, you can crop a raster file to a smaller extent. Learn how to crop raster data using a shapefile and export it as a new raster in open source Python

last updated: 09 Nov 2020

Classify and Plot Raster Data in Python

Reclassifying raster data allows you to use a set of defined values to organize pixel values into new bins or categories. Learn how to classify a raster dataset and export it as a new raster in Python.

last updated: 09 Nov 2020

Open, Plot and Explore Raster Data with Python

Raster data are gridded data composed of pixels that store values, such as an image or elevation data file. Learn how to open, plot, and explore raster files in Python using Rasterio.

last updated: 05 Nov 2020

About the Geotiff (.tif) Raster File Format: Raster Data in Python

Metadata describe the key characteristics of a dataset such as a raster. For spatial data, these characteristics including the coordinate reference system (CRS), resolution and spatial extent. Learn about the use of TIF tags or metadata embedded within a GeoTIFF file to explore the metadata programatically.

last updated: 19 Aug 2021

Plot Histograms of Raster Values in Python

Histograms of raster data provide the distribution of pixel values in the dataset. Learn how to explore and plot the distribution of values within a raster using histograms.

last updated: 06 Nov 2020

What is Raster Data

Rasters are gridded data composed of pixels that store values. Learn more about the structure of raster data and how to use them to store data, such as imagery or elevation values.

last updated: 05 Nov 2020

Understand EPSG, WKT and Other CRS Definition Styles

Coordinate Reference System (CRS) information is often stored in three key formats, including proj.4, EPSG and WKT. Learn more about the ways that coordinate reference system data are stored including proj4, well known text (wkt) and EPSG codes.

last updated: 11 Sep 2020

Geographic vs projected coordinate reference systems - GIS in Python

Geographic coordinate systems span the entire globe (e.g. latitude / longitude), while projected coordinate systems are localized to minimize visual distortion in a particular region (e.g. Robinson, UTM, State Plane). Learn more about key differences between projected vs. geographic coordinate reference systems.

last updated: 11 Sep 2020

GIS in Python: Intro to Coordinate Reference Systems in Python

A coordinate reference system (CRS) defines the translation between a location on the round earth and that same location, on a flattened, 2 dimensional coordinate system. Learn how to explore and reproject data into geographic and projected CRS in Python.

last updated: 11 Sep 2020

Work with MODIS Remote Sensing Data in R.

In this lesson you will explore how to import and work with MODIS remote sensing data in raster geotiff format in R. You will cover importing many files using regular expressions and cleaning raster stack layer names for nice plotting.

last updated: 03 Sep 2019

Clean Remote Sensing Data in R - Clouds, Shadows & Cloud Masks

In this lesson, you will learn how to deal with clouds when working with spectral remote sensing data. You will learn how to mask clouds from landsat and MODIS remote sensing data in R using the mask() function. You will also discuss issues associated with cloud cover - particular as they relate to a research topic.

last updated: 30 Mar 2020

Adjust plot extent in R.

In this lesson you will review how to adjust the extent of a spatial plot in R using the ext() or extent argument and the extent of another layer.

last updated: 03 Sep 2019

Plot Grid of Spatial Plots in R.

In this lesson you learn to use the par() or parameter settings in R to plot several raster RGB plots in R in a grid.

last updated: 03 Sep 2019

Landsat Remote Sensing tif Files in R

In this lesson you will cover the basics of using Landsat 7 and 8 in R. You will learn how to import Landsat data stored in .tif format - where each .tif file represents a single band rather than a stack of bands. Finally you will plot the data using various 3 band combinations including RGB and color-infrared.

last updated: 08 Jan 2020

Calculate NDVI in R: Remote Sensing Vegetation Index

NDVI is calculated using near infrared and red wavelengths or types of light and is used to measure vegetation greenness or health. Learn how to calculate remote sensing NDVI using multispectral imagery in R.

last updated: 03 Sep 2019

How Multispectral Imagery is Drawn on Computers - Additive Color Models

In this lesson you will learn the basics of using Landsat 7 and 8 in R. You will learn how to import Landsat data stored in .tif format - where each .tif file represents a single band rather than a stack of bands. Finally you will plot the data using various 3 band combinations including RGB and color-infrared.

last updated: 03 Sep 2019

How to Open and Work with NAIP Multispectral Imagery in R

In this lesson you learn how to open up a multi-band raster layer or image stored in .tiff format in R. You are introduced to the stack() function in R which can be used to import more than one band into a stack object in R. You also review using plotRGB to plot a multi-band image using RGB, color-infrared to other band combinations.

last updated: 03 Sep 2019

Extract Raster Values Using Vector Boundaries in R

This lesson reviews how to extract pixels from a raster dataset using a vector boundary. You can use the extracted pixels to calculate mean and max tree height for a study area (in this case a field site where tree heights were measured on the ground. Finally you will compare tree heights derived from lidar data compared to tree height measured by humans on the ground.

last updated: 03 Sep 2019

GIS in R: Plot Spatial Data and Create Custom Legends in R

In this lesson you break down the steps required to create a custom legend for spatial data in R. You learn about creating unique symbols per category, customizing colors and placing your legend outside of the plot using the xpd argument combined with x,y placement and margin settings.

last updated: 30 Mar 2020

GIS With R: Projected vs Geographic Coordinate Reference Systems

Geographic coordinate reference systems are often used to make maps of the world. Projected coordinate reference systems are use to optimize spatial analysis for a region. Learn about WGS84 and UTM Coordinate Reference Systems as used in R.

last updated: 13 Mar 2020

Coordinate Reference System and Spatial Projection

Coordinate reference systems are used to convert locations on the earth which is round, to a two dimensional (flat) map. Learn about the differences between coordinate reference systems.

last updated: 03 Sep 2019

Clip Raster in R

You can clip a raster to a polygon extent to save processing time and make image sizes smaller. Learn how to crop a raster dataset in R.

last updated: 13 Mar 2020

Classify a Raster in R.

This lesson presents how to classify a raster dataset and export it as a new raster in R.

last updated: 13 Mar 2020

Create a Canopy Height Model With Lidar Data

A canopy height model contains height values trees and can be used to understand landscape change over time. Learn how to use LIDAR elevation data to calculate canopy height and change in terrain over time.

last updated: 03 Sep 2019

How to Open and Use Files in Geotiff Format

A GeoTIFF is a standard file format with spatial metadata embedded as tags. Use the raster package in R to open geotiff files and spatial metadata programmatically.

last updated: 03 Sep 2019

Plot Histograms of Raster Values in R

This lesson introduces the raster geotiff file format - which is often used to store lidar raster data. You learn the 3 key spatial attributes of a raster dataset including Coordinate reference system, spatial extent and resolution.

last updated: 03 Sep 2019

Introduction to Lidar Raster Data Products

This lesson introduces the raster geotiff file format - which is often used to store lidar raster data. You learn the 3 key spatial attributes of a raster dataset including Coordinate reference system, spatial extent and resolution.

last updated: 13 Mar 2020

What is Lidar Data

This lesson reviews what lidar remote sensing is, what the lidar instrument measures and discusses the core components of a lidar remote sensing system.

last updated: 30 Mar 2020

Compare Lidar to Measured Tree Height

To explore uncertainty in remote sensing data, it is helpful to compare ground-based measurements and data that are collected via airborne instruments or satellites. Learn how to create scatter plots that compare values across two datasets.

last updated: 12 Feb 2021

Extract Raster Values at Point Locations in Python

For many scientific analyses, it is helpful to be able to select raster pixels based on their relationship to a vector dataset (e.g. locations, boundaries). Learn how to extract data from a raster dataset using a vector dataset.

last updated: 02 Feb 2021

Compare Lidar With Human Measured Tree Heights - Remote Sensing Uncertainty

Uncertainty quantifies a range of values within which a measurement value could be within, considering a specified level of confidence. Learn about the types of uncertainty that you can expect when working with tree height data both derived from lidar remote sensing and human measurements and learn about sources of error including systematic vs. random error.

last updated: 02 Feb 2021