Introduction to Spatial Raster Data in Open Source Python
Welcome to Week 12!
Welcome to Week 12 of the Earth Analytics Bootcamp course! This week, you will write Python
code in Jupyter Notebook
to work with spatial raster data.
Learning Objectives
After completing the lessons for Week 12, you will be able to:
- Open and plot raster data using xarray in Python
- Crop raster data using rioxarray
- Manually classify raster data
- Perform basic raster math
Homework & Readings
Click here to view the GitHub Repo with the assignment template.
Earth Data Science Textbook Readings
Please read the following chapters of the Intermediate to Earth Data Science online textbook to support completing this week’s assignment:
Please read and watch the following chapters in the of the Intermediate Earth Data Science online textbook to support completing this week’s assignment:
Example Homework Plots
Below are example versions of the plots you will create for your homework.
![Plots of lidar min and max vs insitu min and max with a 1:1 line a regression fit for the NEON SJER field site.](https://www.earthdatascience.org/images/courses/ea-bootcamp/12-raster-data/2018-08-07-raster-data-landing-page/2018-08-07-raster-data-landing-page_7_0.png)
![Histogram of values from the raster plot of the difference in the canopy height model.](https://www.earthdatascience.org/images/courses/ea-bootcamp/12-raster-data/2018-08-07-raster-data-landing-page/2018-08-07-raster-data-landing-page_8_0.png)
![Categorized raster of areas that gained or lost elevation after the flood.](https://www.earthdatascience.org/images/courses/ea-bootcamp/12-raster-data/2018-08-07-raster-data-landing-page/2018-08-07-raster-data-landing-page_9_0.png)
# HW plot 6
# PLOT 3: pre/post DTM difference raster histogram
bins = [-15, -5, -2, 0, 2, 5, 15]
diff_dtm = post_dtm_xr_cl - pre_dtm_xr_cl
diff_dsm = post_dsm_xr_cl - pre_dsm_xr_cl
f, (ax1, ax2) = plt.subplots(2, 1, figsize=(10, 10), sharey=True)
diff_dtm.plot.hist(bins=bins,
ax=ax1)
ax1.set(title="DTM Difference Histogram")
diff_dsm.plot.hist(bins=bins,
ax=ax2)
ax2.set(title="DSM Difference Histogram")
plt.show()
![Two histogram plots. The top plot shows the values found in the difference raster of the digital terrain model. The bottom plot shows the values found in the difference raster of the digital surface model.](https://www.earthdatascience.org/images/courses/ea-bootcamp/12-raster-data/2018-08-07-raster-data-landing-page/2018-08-07-raster-data-landing-page_10_0.png)
Share on
Twitter Facebook Google+ LinkedIn![Get a professional Certificate in Earth Data Analytics at University of Colorado, Boulder](https://www.earthdatascience.org/images/earth-data-analytics-professional-certificate-banner.png)