SlideShare a Scribd company logo
1 of 18
Climate data in R with the raster package Jacob van Etten
Packages There are many packages specifically created for R that allow you to do specialized tasks. One of these packages is raster, created by Robert Hijmans and Jacob van Etten (mainly the former, though). The raster package allows you to work with geographical grid (raster) data.
Get raster in RStudio Click on the “Packages” tab in the lower right corner. Click “Install Packages”. Type “raster” and click on “Install”. Leave “Install dependencies” checked. This will also get some other essential packages.
Load the package With the following command, we load the package into R. Make sure you put this in the first line of your new script. library(raster) help(package="raster") Thesecondfunctiongivesyouanoverview of thefunctions in thepackage.
The raster() function The main function to read raster data into R is called (very conveniently) raster. ?raster Let’s make a raster! r1 <- raster() r1 As you can see, there are no values in the raster. Next thing to solve.
Adding values How many values do we need to fill the raster? The function ncell() will tell us. n <- ncell(r1) Let’s make a vector with n random values between 0 and 1 with the function runif(). vals<- runif(n) And we add the values to the raster. values(r1) <- vals
Raster graphics We make a picture of the raster we just made. plot(r1, main=“My first raster map in R”) Now let’s take a look at the different options that plot() gives. ?plot Click “Plot a Raster* object”. Also, take a look at the examples and try some if you want.
Real data Let’s get some real data to play with. http://goo.gl/4488T This is a raster representing current conditions (a bit over 1 MB). Unzip the file, and put it in a (new) folder. Now make this folder your working directory in R. setwd(“D:/yourfolder”)
Getting raster data into R Reading this data into R is really easy now. r2 <- raster(“current_bio_1_1.asc”) What class is this raster? class(r2) Plot this raster.
Cutting an area of interest The function extents requires a vector of 4 values: {xmin, xmax, ymin, ymax}. For instance: newExtent <- extent(c(60, 100, 0, 40)) Orchooseyourownarea of interest, forinstanceusing Google Earth. Then cut the new extent out of r2 and visualize. r3 <- crop(r2, newExtent) plot(r3)
Raster algebra It is very convenient to calculate with rasters. Try this and visualize the result. r4 <- r3 + sqrt(r3) What happens when you do the following and why? r5 <- r2 + r3
Some operations Aggregating cells means the grid becomes coarser. By default the function aggregate() will take the mean of the cells it will aggregate. r6 <- aggregate(r2, fact=2) Now take a look at the examples under ?aggregate and try to understand what happens.
Interpolation See if you can work this out for yourself. Take a look at the first example of  ?interpolate
Sources of data For an overview of a lot of relevant climate and weather data, visit this website: http://iridl.ldeo.columbia.edu/
Moreover... Worldclim data are global climate data (get it using the raster package, getData function) NCDC-NOAA – Global Summary of Day, weather data from thousands of stations (weatherData package) CCAFS data
Worldclim Precipitation at 10 minute resolution wc <- getData(“worldclim”, var=“prec”, res=10) plot(wc)
Global Summary of Day Available from: ftp://ftp.ncdc.noaa.gov/pub/data/gsod/ These data are massive. Use the weatherData package to download these data.
Climate data analysis in R with the raster package

More Related Content

What's hot

Satellite image processing
Satellite image processingSatellite image processing
Satellite image processingalok ray
 
Pactices of GPS/GIS in/for rural development
Pactices of GPS/GIS in/for rural developmentPactices of GPS/GIS in/for rural development
Pactices of GPS/GIS in/for rural developmentTakahiro Miyoshi
 
GIS LANDSLIDES ANALYSIS ii
GIS LANDSLIDES ANALYSIS iiGIS LANDSLIDES ANALYSIS ii
GIS LANDSLIDES ANALYSIS iiEdmundo Zevallos
 
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GISLANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GISAditya Ghumare
 
Processing Rasters from Satellites, Drones, & More
Processing Rasters from Satellites, Drones, & MoreProcessing Rasters from Satellites, Drones, & More
Processing Rasters from Satellites, Drones, & MoreSafe Software
 
Habitat suitability of One horned Rhinoceros using GIS.pptx
Habitat suitability of One horned Rhinoceros using GIS.pptxHabitat suitability of One horned Rhinoceros using GIS.pptx
Habitat suitability of One horned Rhinoceros using GIS.pptxsahl_2fast
 
Spatial interpolation techniques
Spatial interpolation techniquesSpatial interpolation techniques
Spatial interpolation techniquesManisha Shrivastava
 
Remote Sensing: Normalized Difference Vegetation Index (NDVI)
Remote Sensing: Normalized Difference Vegetation Index (NDVI)Remote Sensing: Normalized Difference Vegetation Index (NDVI)
Remote Sensing: Normalized Difference Vegetation Index (NDVI)Kamlesh Kumar
 
Ppt on remote sensing system
Ppt on remote sensing systemPpt on remote sensing system
Ppt on remote sensing systemAlisha Korpal
 
Projections and coordinate system
Projections and coordinate systemProjections and coordinate system
Projections and coordinate systemMohsin Siddique
 
spatial anaylisi using ilwis
spatial anaylisi using ilwisspatial anaylisi using ilwis
spatial anaylisi using ilwisAsri Renggo
 
Emr intraction with atmosphere
Emr intraction with atmosphereEmr intraction with atmosphere
Emr intraction with atmosphereRahat Hasan
 
Thermal remote sensing BY Hariom Ahlawat
Thermal remote sensing BY Hariom AhlawatThermal remote sensing BY Hariom Ahlawat
Thermal remote sensing BY Hariom AhlawatHariom Ahlawat
 
Using GIS Technology to Improve Emergency Management
Using GIS Technology to Improve Emergency ManagementUsing GIS Technology to Improve Emergency Management
Using GIS Technology to Improve Emergency ManagementAmberStacy
 

What's hot (20)

Satellite image processing
Satellite image processingSatellite image processing
Satellite image processing
 
Pactices of GPS/GIS in/for rural development
Pactices of GPS/GIS in/for rural developmentPactices of GPS/GIS in/for rural development
Pactices of GPS/GIS in/for rural development
 
Bhuvan
BhuvanBhuvan
Bhuvan
 
GIS LANDSLIDES ANALYSIS ii
GIS LANDSLIDES ANALYSIS iiGIS LANDSLIDES ANALYSIS ii
GIS LANDSLIDES ANALYSIS ii
 
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GISLANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
LANDSLIDE HAZARD ZONATION MAPPING USING RS AND GIS
 
Processing Rasters from Satellites, Drones, & More
Processing Rasters from Satellites, Drones, & MoreProcessing Rasters from Satellites, Drones, & More
Processing Rasters from Satellites, Drones, & More
 
Habitat suitability of One horned Rhinoceros using GIS.pptx
Habitat suitability of One horned Rhinoceros using GIS.pptxHabitat suitability of One horned Rhinoceros using GIS.pptx
Habitat suitability of One horned Rhinoceros using GIS.pptx
 
Spatial interpolation techniques
Spatial interpolation techniquesSpatial interpolation techniques
Spatial interpolation techniques
 
Remote Sensing: Normalized Difference Vegetation Index (NDVI)
Remote Sensing: Normalized Difference Vegetation Index (NDVI)Remote Sensing: Normalized Difference Vegetation Index (NDVI)
Remote Sensing: Normalized Difference Vegetation Index (NDVI)
 
Technologies for natural disaster
Technologies for natural disasterTechnologies for natural disaster
Technologies for natural disaster
 
Historical Development of Photogrammetry
Historical Development of PhotogrammetryHistorical Development of Photogrammetry
Historical Development of Photogrammetry
 
Ppt on remote sensing system
Ppt on remote sensing systemPpt on remote sensing system
Ppt on remote sensing system
 
Projections and coordinate system
Projections and coordinate systemProjections and coordinate system
Projections and coordinate system
 
Digital Elevation Model (DEM)
Digital Elevation Model (DEM)Digital Elevation Model (DEM)
Digital Elevation Model (DEM)
 
Introduction to GIS
Introduction to GISIntroduction to GIS
Introduction to GIS
 
spatial anaylisi using ilwis
spatial anaylisi using ilwisspatial anaylisi using ilwis
spatial anaylisi using ilwis
 
datum
datumdatum
datum
 
Emr intraction with atmosphere
Emr intraction with atmosphereEmr intraction with atmosphere
Emr intraction with atmosphere
 
Thermal remote sensing BY Hariom Ahlawat
Thermal remote sensing BY Hariom AhlawatThermal remote sensing BY Hariom Ahlawat
Thermal remote sensing BY Hariom Ahlawat
 
Using GIS Technology to Improve Emergency Management
Using GIS Technology to Improve Emergency ManagementUsing GIS Technology to Improve Emergency Management
Using GIS Technology to Improve Emergency Management
 

Viewers also liked

Edwards climate data detectives - yale 2-2015
Edwards   climate data detectives - yale 2-2015Edwards   climate data detectives - yale 2-2015
Edwards climate data detectives - yale 2-2015Paul Edwards
 
Interpreting Climate Data - Analysing climate vulnerability- online training ...
Interpreting Climate Data - Analysing climate vulnerability- online training ...Interpreting Climate Data - Analysing climate vulnerability- online training ...
Interpreting Climate Data - Analysing climate vulnerability- online training ...Vestlandsforsking WRNI
 
Climate Data Sharing for Urban Resilience - OGC Testbed 11
Climate Data Sharing for Urban Resilience - OGC Testbed 11Climate Data Sharing for Urban Resilience - OGC Testbed 11
Climate Data Sharing for Urban Resilience - OGC Testbed 11George Percivall
 
Document IT Communicate IT Succeed
Document IT Communicate IT SucceedDocument IT Communicate IT Succeed
Document IT Communicate IT SucceedDeborah Gleason
 
Contextualizing the Visualization of Climate Data
Contextualizing the Visualization of Climate DataContextualizing the Visualization of Climate Data
Contextualizing the Visualization of Climate DataRaquel Alegre
 
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...Francisco Ramos
 
Data recovery saudi arabia
Data recovery saudi arabiaData recovery saudi arabia
Data recovery saudi arabiaDolphin Data Lab
 
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)ICLR Friday Forum: Climate data in Ontario (November 13, 2015)
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)glennmcgillivray
 
20090701 Climate Data Staging
20090701 Climate Data Staging20090701 Climate Data Staging
20090701 Climate Data StagingHenning Bergmeyer
 
Saudi arabia climate policy report
Saudi arabia climate policy reportSaudi arabia climate policy report
Saudi arabia climate policy reportAaron Dorman
 
Geography Water
Geography WaterGeography Water
Geography WaterDaniela L
 
Collaborate 2012: Environmental Accounting and Reporting
Collaborate 2012: Environmental Accounting and ReportingCollaborate 2012: Environmental Accounting and Reporting
Collaborate 2012: Environmental Accounting and ReportingAngela Miller
 
Saudi arabia presentation
Saudi arabia presentationSaudi arabia presentation
Saudi arabia presentationbpdow12
 
BigDataEurope - Big Data & Climate Change
BigDataEurope - Big Data & Climate ChangeBigDataEurope - Big Data & Climate Change
BigDataEurope - Big Data & Climate ChangeBigData_Europe
 
Saudi Aramco Carbon Management - May 2013
Saudi Aramco Carbon Management - May 2013Saudi Aramco Carbon Management - May 2013
Saudi Aramco Carbon Management - May 2013Global CCS Institute
 
The Role of DAta for Climate Monitoring and Prediction
The Role of DAta for Climate Monitoring and PredictionThe Role of DAta for Climate Monitoring and Prediction
The Role of DAta for Climate Monitoring and PredictionNAP Events
 

Viewers also liked (20)

Edwards climate data detectives - yale 2-2015
Edwards   climate data detectives - yale 2-2015Edwards   climate data detectives - yale 2-2015
Edwards climate data detectives - yale 2-2015
 
Andreas Hense: Climate data for our future – acquired, analysed, archived
Andreas Hense: Climate data for our future – acquired, analysed, archivedAndreas Hense: Climate data for our future – acquired, analysed, archived
Andreas Hense: Climate data for our future – acquired, analysed, archived
 
Interpreting Climate Data - Analysing climate vulnerability- online training ...
Interpreting Climate Data - Analysing climate vulnerability- online training ...Interpreting Climate Data - Analysing climate vulnerability- online training ...
Interpreting Climate Data - Analysing climate vulnerability- online training ...
 
Climate Data Sharing for Urban Resilience - OGC Testbed 11
Climate Data Sharing for Urban Resilience - OGC Testbed 11Climate Data Sharing for Urban Resilience - OGC Testbed 11
Climate Data Sharing for Urban Resilience - OGC Testbed 11
 
Document IT Communicate IT Succeed
Document IT Communicate IT SucceedDocument IT Communicate IT Succeed
Document IT Communicate IT Succeed
 
Contextualizing the Visualization of Climate Data
Contextualizing the Visualization of Climate DataContextualizing the Visualization of Climate Data
Contextualizing the Visualization of Climate Data
 
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...
ESRI User Conference 2014 - A Location Aware Mobile Tool for Direct and Indir...
 
Data recovery saudi arabia
Data recovery saudi arabiaData recovery saudi arabia
Data recovery saudi arabia
 
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)ICLR Friday Forum: Climate data in Ontario (November 13, 2015)
ICLR Friday Forum: Climate data in Ontario (November 13, 2015)
 
20090701 Climate Data Staging
20090701 Climate Data Staging20090701 Climate Data Staging
20090701 Climate Data Staging
 
Saudi arabia climate policy report
Saudi arabia climate policy reportSaudi arabia climate policy report
Saudi arabia climate policy report
 
Geography Water
Geography WaterGeography Water
Geography Water
 
Collaborate 2012: Environmental Accounting and Reporting
Collaborate 2012: Environmental Accounting and ReportingCollaborate 2012: Environmental Accounting and Reporting
Collaborate 2012: Environmental Accounting and Reporting
 
Saudi arabia presentation
Saudi arabia presentationSaudi arabia presentation
Saudi arabia presentation
 
Making Climate Data Sing
Making Climate Data SingMaking Climate Data Sing
Making Climate Data Sing
 
BigDataEurope - Big Data & Climate Change
BigDataEurope - Big Data & Climate ChangeBigDataEurope - Big Data & Climate Change
BigDataEurope - Big Data & Climate Change
 
Saudi Aramco Carbon Management - May 2013
Saudi Aramco Carbon Management - May 2013Saudi Aramco Carbon Management - May 2013
Saudi Aramco Carbon Management - May 2013
 
The Role of DAta for Climate Monitoring and Prediction
The Role of DAta for Climate Monitoring and PredictionThe Role of DAta for Climate Monitoring and Prediction
The Role of DAta for Climate Monitoring and Prediction
 
Non-renewable groundwater management in Saudi Arabia
Non-renewable groundwater management in Saudi ArabiaNon-renewable groundwater management in Saudi Arabia
Non-renewable groundwater management in Saudi Arabia
 
Gulf Region
Gulf RegionGulf Region
Gulf Region
 

Similar to Climate data analysis in R with the raster package

Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster packageAlberto Labarga
 
ComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciencesalexstorer
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiUnmesh Baile
 
R programming slides
R  programming slidesR  programming slides
R programming slidesPankaj Saini
 
20130215 Reading data into R
20130215 Reading data into R20130215 Reading data into R
20130215 Reading data into RKazuki Yoshida
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programmingAlberto Labarga
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Hands on data science with r.pptx
Hands  on data science with r.pptxHands  on data science with r.pptx
Hands on data science with r.pptxNimrita Koul
 
Transformations and actions a visual guide training
Transformations and actions a visual guide trainingTransformations and actions a visual guide training
Transformations and actions a visual guide trainingSpark Summit
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptanshikagoel52
 

Similar to Climate data analysis in R with the raster package (20)

Climate data in r with the raster package
Climate data in r with the raster packageClimate data in r with the raster package
Climate data in r with the raster package
 
ComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical SciencesComputeFest 2012: Intro To R for Physical Sciences
ComputeFest 2012: Intro To R for Physical Sciences
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
Unit 3
Unit 3Unit 3
Unit 3
 
Lecture_R.ppt
Lecture_R.pptLecture_R.ppt
Lecture_R.ppt
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
 
Aggregate.pptx
Aggregate.pptxAggregate.pptx
Aggregate.pptx
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي   R program د.هديل القفيديمحاضرة برنامج التحليل الكمي   R program د.هديل القفيدي
محاضرة برنامج التحليل الكمي R program د.هديل القفيدي
 
20130215 Reading data into R
20130215 Reading data into R20130215 Reading data into R
20130215 Reading data into R
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
 
R Introduction
R IntroductionR Introduction
R Introduction
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Hands on data science with r.pptx
Hands  on data science with r.pptxHands  on data science with r.pptx
Hands on data science with r.pptx
 
Transformations and actions a visual guide training
Transformations and actions a visual guide trainingTransformations and actions a visual guide training
Transformations and actions a visual guide training
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Devtools cheatsheet
Devtools cheatsheetDevtools cheatsheet
Devtools cheatsheet
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
 

More from CCAFS | CGIAR Research Program on Climate Change, Agriculture and Food Security

More from CCAFS | CGIAR Research Program on Climate Change, Agriculture and Food Security (20)

CGIAR-AICCRA Knowledge Management Guide (2021)
CGIAR-AICCRA Knowledge Management Guide (2021)CGIAR-AICCRA Knowledge Management Guide (2021)
CGIAR-AICCRA Knowledge Management Guide (2021)
 
Achieving NDC Ambition in Agriculture: How much does agriculture contribute t...
Achieving NDC Ambition in Agriculture: How much does agriculture contribute t...Achieving NDC Ambition in Agriculture: How much does agriculture contribute t...
Achieving NDC Ambition in Agriculture: How much does agriculture contribute t...
 
Achieving NDC Ambition in Agriculture: Mitigation ambition in new & updated N...
Achieving NDC Ambition in Agriculture: Mitigation ambition in new & updated N...Achieving NDC Ambition in Agriculture: Mitigation ambition in new & updated N...
Achieving NDC Ambition in Agriculture: Mitigation ambition in new & updated N...
 
Achieving NDC Ambition in Agriculture: Overview of NDC ambition in the agricu...
Achieving NDC Ambition in Agriculture: Overview of NDC ambition in the agricu...Achieving NDC Ambition in Agriculture: Overview of NDC ambition in the agricu...
Achieving NDC Ambition in Agriculture: Overview of NDC ambition in the agricu...
 
CCAFS and GRA Resources for CLIFF-GRADS 2021
CCAFS and GRA Resources for CLIFF-GRADS 2021CCAFS and GRA Resources for CLIFF-GRADS 2021
CCAFS and GRA Resources for CLIFF-GRADS 2021
 
CSA Monitoring: Understanding adoption, synergies and tradeoffs at farm and h...
CSA Monitoring: Understanding adoption, synergies and tradeoffs at farm and h...CSA Monitoring: Understanding adoption, synergies and tradeoffs at farm and h...
CSA Monitoring: Understanding adoption, synergies and tradeoffs at farm and h...
 
Livestock and sustainability in changing climate: Impacts and global best pra...
Livestock and sustainability in changing climate: Impacts and global best pra...Livestock and sustainability in changing climate: Impacts and global best pra...
Livestock and sustainability in changing climate: Impacts and global best pra...
 
Plant-based protein market in Asia
Plant-based protein market in AsiaPlant-based protein market in Asia
Plant-based protein market in Asia
 
ADB ESLAP case study outputs and synthesis results: Sustainable livestock gui...
ADB ESLAP case study outputs and synthesis results: Sustainable livestock gui...ADB ESLAP case study outputs and synthesis results: Sustainable livestock gui...
ADB ESLAP case study outputs and synthesis results: Sustainable livestock gui...
 
ADB ESLAP Case Study "Dairy value chain in Indonesia"
ADB ESLAP Case Study "Dairy value chain in Indonesia"ADB ESLAP Case Study "Dairy value chain in Indonesia"
ADB ESLAP Case Study "Dairy value chain in Indonesia"
 
Assessment of the environmental sustainability of plant-based meat and pork: ...
Assessment of the environmental sustainability of plant-based meat and pork: ...Assessment of the environmental sustainability of plant-based meat and pork: ...
Assessment of the environmental sustainability of plant-based meat and pork: ...
 
Case study on dairy value chain in China
Case study on dairy value chain in ChinaCase study on dairy value chain in China
Case study on dairy value chain in China
 
Global sustainable livestock investment overview
Global sustainable livestock investment overviewGlobal sustainable livestock investment overview
Global sustainable livestock investment overview
 
The impact of mechanization in smallholder rice production in Nigeria
The impact of mechanization in smallholder rice production in NigeriaThe impact of mechanization in smallholder rice production in Nigeria
The impact of mechanization in smallholder rice production in Nigeria
 
Biodiversity in agriculture for people and planet
Biodiversity in agriculture for people and planetBiodiversity in agriculture for people and planet
Biodiversity in agriculture for people and planet
 
Greenhouse gas (GHG) emissions & priority action in climate mitigation in the...
Greenhouse gas (GHG) emissions & priority action in climate mitigation in the...Greenhouse gas (GHG) emissions & priority action in climate mitigation in the...
Greenhouse gas (GHG) emissions & priority action in climate mitigation in the...
 
Evaluation of Rwanda climate services for agriculture through a gender lens
Evaluation of Rwanda climate services for agriculture through a gender lensEvaluation of Rwanda climate services for agriculture through a gender lens
Evaluation of Rwanda climate services for agriculture through a gender lens
 
Introduction to Climate-Smart Agriculture: Busia County, Kenya
Introduction to Climate-Smart Agriculture: Busia County, KenyaIntroduction to Climate-Smart Agriculture: Busia County, Kenya
Introduction to Climate-Smart Agriculture: Busia County, Kenya
 
Delivering information for national low-emission development strategies: acti...
Delivering information for national low-emission development strategies: acti...Delivering information for national low-emission development strategies: acti...
Delivering information for national low-emission development strategies: acti...
 
Delivering information for national low-emission development strategies: acti...
Delivering information for national low-emission development strategies: acti...Delivering information for national low-emission development strategies: acti...
Delivering information for national low-emission development strategies: acti...
 

Recently uploaded

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 

Recently uploaded (20)

TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 

Climate data analysis in R with the raster package

  • 1. Climate data in R with the raster package Jacob van Etten
  • 2. Packages There are many packages specifically created for R that allow you to do specialized tasks. One of these packages is raster, created by Robert Hijmans and Jacob van Etten (mainly the former, though). The raster package allows you to work with geographical grid (raster) data.
  • 3. Get raster in RStudio Click on the “Packages” tab in the lower right corner. Click “Install Packages”. Type “raster” and click on “Install”. Leave “Install dependencies” checked. This will also get some other essential packages.
  • 4. Load the package With the following command, we load the package into R. Make sure you put this in the first line of your new script. library(raster) help(package="raster") Thesecondfunctiongivesyouanoverview of thefunctions in thepackage.
  • 5. The raster() function The main function to read raster data into R is called (very conveniently) raster. ?raster Let’s make a raster! r1 <- raster() r1 As you can see, there are no values in the raster. Next thing to solve.
  • 6. Adding values How many values do we need to fill the raster? The function ncell() will tell us. n <- ncell(r1) Let’s make a vector with n random values between 0 and 1 with the function runif(). vals<- runif(n) And we add the values to the raster. values(r1) <- vals
  • 7. Raster graphics We make a picture of the raster we just made. plot(r1, main=“My first raster map in R”) Now let’s take a look at the different options that plot() gives. ?plot Click “Plot a Raster* object”. Also, take a look at the examples and try some if you want.
  • 8. Real data Let’s get some real data to play with. http://goo.gl/4488T This is a raster representing current conditions (a bit over 1 MB). Unzip the file, and put it in a (new) folder. Now make this folder your working directory in R. setwd(“D:/yourfolder”)
  • 9. Getting raster data into R Reading this data into R is really easy now. r2 <- raster(“current_bio_1_1.asc”) What class is this raster? class(r2) Plot this raster.
  • 10. Cutting an area of interest The function extents requires a vector of 4 values: {xmin, xmax, ymin, ymax}. For instance: newExtent <- extent(c(60, 100, 0, 40)) Orchooseyourownarea of interest, forinstanceusing Google Earth. Then cut the new extent out of r2 and visualize. r3 <- crop(r2, newExtent) plot(r3)
  • 11. Raster algebra It is very convenient to calculate with rasters. Try this and visualize the result. r4 <- r3 + sqrt(r3) What happens when you do the following and why? r5 <- r2 + r3
  • 12. Some operations Aggregating cells means the grid becomes coarser. By default the function aggregate() will take the mean of the cells it will aggregate. r6 <- aggregate(r2, fact=2) Now take a look at the examples under ?aggregate and try to understand what happens.
  • 13. Interpolation See if you can work this out for yourself. Take a look at the first example of ?interpolate
  • 14. Sources of data For an overview of a lot of relevant climate and weather data, visit this website: http://iridl.ldeo.columbia.edu/
  • 15. Moreover... Worldclim data are global climate data (get it using the raster package, getData function) NCDC-NOAA – Global Summary of Day, weather data from thousands of stations (weatherData package) CCAFS data
  • 16. Worldclim Precipitation at 10 minute resolution wc <- getData(“worldclim”, var=“prec”, res=10) plot(wc)
  • 17. Global Summary of Day Available from: ftp://ftp.ncdc.noaa.gov/pub/data/gsod/ These data are massive. Use the weatherData package to download these data.