SlideShare ist ein Scribd-Unternehmen logo
1 von 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.
Raster package jacob

Weitere ähnliche Inhalte

Was ist angesagt?

Processing Geospatial Data At Scale @locationtech
Processing Geospatial Data At Scale @locationtechProcessing Geospatial Data At Scale @locationtech
Processing Geospatial Data At Scale @locationtechRob Emanuele
 
[@NaukriEngineering] Apache Spark
[@NaukriEngineering] Apache Spark[@NaukriEngineering] Apache Spark
[@NaukriEngineering] Apache SparkNaukri.com
 
Stratosphere with big_data_analytics
Stratosphere with big_data_analyticsStratosphere with big_data_analytics
Stratosphere with big_data_analyticsAvinash Pandu
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech ProjectsJody Garnett
 
Applying stratosphere for big data analytics
Applying stratosphere for big data analyticsApplying stratosphere for big data analytics
Applying stratosphere for big data analyticsAvinash Pandu
 
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasetsRob Emanuele
 
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other OptimizationsMastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other Optimizationsscottcrespo
 
Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Samir Bessalah
 
Hadoop institutes-in-bangalore
Hadoop institutes-in-bangaloreHadoop institutes-in-bangalore
Hadoop institutes-in-bangaloreKelly Technologies
 
Bioclouds CAMDA (Robert Grossman) 09-v9p
Bioclouds CAMDA (Robert Grossman) 09-v9pBioclouds CAMDA (Robert Grossman) 09-v9p
Bioclouds CAMDA (Robert Grossman) 09-v9pRobert Grossman
 
Locality Sensitive Hashing By Spark
Locality Sensitive Hashing By SparkLocality Sensitive Hashing By Spark
Locality Sensitive Hashing By SparkSpark Summit
 
AWS Roadshow Herbst 2013: Datenanalyse und Business Intelligence
AWS Roadshow Herbst 2013: Datenanalyse und Business IntelligenceAWS Roadshow Herbst 2013: Datenanalyse und Business Intelligence
AWS Roadshow Herbst 2013: Datenanalyse und Business IntelligenceAWS Germany
 
Raster Processing with Scipy.ndimage (Dev Meet Up II)
Raster Processing with Scipy.ndimage (Dev Meet Up II)Raster Processing with Scipy.ndimage (Dev Meet Up II)
Raster Processing with Scipy.ndimage (Dev Meet Up II)JHasthorpe
 
The maths behind microscaling
The maths behind microscalingThe maths behind microscaling
The maths behind microscalingLiz Rice
 
Streaming API, Spark and Ruby
Streaming API, Spark and RubyStreaming API, Spark and Ruby
Streaming API, Spark and RubyManohar Amrutkar
 
Weather Data Analytics Using Hadoop
Weather Data Analytics Using HadoopWeather Data Analytics Using Hadoop
Weather Data Analytics Using HadoopNajima Begum
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce Fabio Fumarola
 

Was ist angesagt? (20)

Processing Geospatial Data At Scale @locationtech
Processing Geospatial Data At Scale @locationtechProcessing Geospatial Data At Scale @locationtech
Processing Geospatial Data At Scale @locationtech
 
SparkNotes
SparkNotesSparkNotes
SparkNotes
 
[@NaukriEngineering] Apache Spark
[@NaukriEngineering] Apache Spark[@NaukriEngineering] Apache Spark
[@NaukriEngineering] Apache Spark
 
Stratosphere with big_data_analytics
Stratosphere with big_data_analyticsStratosphere with big_data_analytics
Stratosphere with big_data_analytics
 
LocationTech Projects
LocationTech ProjectsLocationTech Projects
LocationTech Projects
 
Applying stratosphere for big data analytics
Applying stratosphere for big data analyticsApplying stratosphere for big data analytics
Applying stratosphere for big data analytics
 
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets
2021 Dask Summit - Using STAC to catalog SpatioTemporal datasets
 
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other OptimizationsMastering Hadoop Map Reduce - Custom Types and Other Optimizations
Mastering Hadoop Map Reduce - Custom Types and Other Optimizations
 
Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013Big Data Analytics with Scala at SCALA.IO 2013
Big Data Analytics with Scala at SCALA.IO 2013
 
Hadoop institutes-in-bangalore
Hadoop institutes-in-bangaloreHadoop institutes-in-bangalore
Hadoop institutes-in-bangalore
 
chapter - 6.ppt
chapter - 6.pptchapter - 6.ppt
chapter - 6.ppt
 
MapReduce basic
MapReduce basicMapReduce basic
MapReduce basic
 
Bioclouds CAMDA (Robert Grossman) 09-v9p
Bioclouds CAMDA (Robert Grossman) 09-v9pBioclouds CAMDA (Robert Grossman) 09-v9p
Bioclouds CAMDA (Robert Grossman) 09-v9p
 
Locality Sensitive Hashing By Spark
Locality Sensitive Hashing By SparkLocality Sensitive Hashing By Spark
Locality Sensitive Hashing By Spark
 
AWS Roadshow Herbst 2013: Datenanalyse und Business Intelligence
AWS Roadshow Herbst 2013: Datenanalyse und Business IntelligenceAWS Roadshow Herbst 2013: Datenanalyse und Business Intelligence
AWS Roadshow Herbst 2013: Datenanalyse und Business Intelligence
 
Raster Processing with Scipy.ndimage (Dev Meet Up II)
Raster Processing with Scipy.ndimage (Dev Meet Up II)Raster Processing with Scipy.ndimage (Dev Meet Up II)
Raster Processing with Scipy.ndimage (Dev Meet Up II)
 
The maths behind microscaling
The maths behind microscalingThe maths behind microscaling
The maths behind microscaling
 
Streaming API, Spark and Ruby
Streaming API, Spark and RubyStreaming API, Spark and Ruby
Streaming API, Spark and Ruby
 
Weather Data Analytics Using Hadoop
Weather Data Analytics Using HadoopWeather Data Analytics Using Hadoop
Weather Data Analytics Using Hadoop
 
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
A Parallel Algorithm for Approximate Frequent Itemset Mining using MapReduce
 

Ähnlich wie Raster package jacob

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
 

Ähnlich wie Raster package jacob (20)

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
 
Lecture1 r
Lecture1 rLecture1 r
Lecture1 r
 
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
 

Mehr von CCAFS | CGIAR Research Program on Climate Change, Agriculture and Food Security

Mehr von 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...
 

Kürzlich hochgeladen

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Kürzlich hochgeladen (20)

Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Raster package jacob

  • 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.