2010-07-26

Extracting Raster Values from Points in R and GRASS

A common task in GIS analysis is to extract the value of a remotely sensed environmental variable at a point location. For instance we may wish to extract the elevation of a field plot from a digital elevation model. The elevation data is a raster (i.e. grid) and the plots are a point shapefile (or a simple text file of X, Y locations). The command for doing this in ArcGIS is ExtractValuesToPoints available in the Spatial Analyst package. Situations may arise where ArcGIS is not the most efficient way of extracting these values. So, here, I provide a brief overview of how to extract raster values to points in R and GRASS.

Extract Values to Points in R

This is strikingly easy is R. My work usually requires more statistical sophistication than is available in ArcGIS. As a result, I have completely switched to doing the extraction in R. I known I am going to end in R eventually, and it is easier to automate than writing a long python script in ArcGIS.

Data required

For the purpose of this exercise. All the data must be have the same spatial projection.

gr.asc
an ESRI ASCII grid. This could also be an ArcGIS binary grid if you know how to use RGDAL. That perhaps will be another post.
pt.shp
a point shapefile.

You also need the maptools and sp packages.

The Code

That is it. Fast, and easy.

Extracting Values in GRASS

Extracting raster values in GRASS is somewhat faster than in R, but it takes a little bit more planning in that you have to explicitly create the column that the raster values will go into.

Data Required

  • gr : A GRASS grid
  • pt : A GRASS point dataset

The Code

The basic flow of this is that you create an empty column in the point dataset with the right data type (i.e. varchar(10) string of length 10, double precision floating point numbers, int integers). Then, fill the column with the raster values.

Labels: , ,

87 Comments:

Blogger Lori said...

Can this be done with multiple ASCIIs at the same time? I want to extract WorldClim variables to species presence points.

June 22, 2011 at 12:35 PM  
Blogger Admin said...

Dear Todd,
Thanks for the nice posting.

I modified your solution according to my need(skipped the grass part and make workable for multiple raster files) and posted my solution in http://gis-techniques.blogspot.com/2012/10/extract-raster-values-from-points.html.

October 11, 2012 at 6:01 PM  
Blogger Unknown said...

Latest Govtapply Jobs 2016

Thanks to sharing this nice information i really appreciate your thinking.......

February 15, 2016 at 4:23 AM  
Blogger raphael said...

Wow amazing i saw this article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing.

digital marketing training Chennai

February 26, 2016 at 12:23 AM  
Blogger henris said...

Thank you for posting it will be helpful by knowing more about GDAL. Thank you and please keep update like this with this site. Definitely it will be useful for all.


SQL DBA Training in Chennai

March 4, 2016 at 4:03 AM  
Blogger Konnie said...

Hi. When I run the R code with m data I'm getting following error message:

Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘overlay’ for signature ‘"SpatialGridDataFrame", "SpatialPointsDataFrame"’.

Any ideas why? regards, Konnie

March 18, 2016 at 9:06 PM  
Blogger Ridhima said...

Thanks for the good words! Really appreciated. Great post. I’ve been commenting a lot on a few blogs recently, but I hadn’t thought about my approach until you brought it up.

SEO training in Adyar

April 2, 2016 at 11:07 AM  
Blogger Luxuryboatsalgarve said...

It's nice blog I have really enjoyed keeping up with you on this blog.This is very useful post for everyone. Thank you so much this post.


__________________________
Washington dc dog training

April 7, 2016 at 1:01 AM  
Anonymous Anonymous said...

This comment has been removed by the author.

August 14, 2016 at 10:13 AM  
Blogger Katy said...

This comment has been removed by the author.

November 21, 2016 at 6:03 AM  
Blogger Kavya said...

Sarkari Recruitment is one of the biggest Indian Job Site so here you will getLatest Govt Jobs 2017so

December 29, 2016 at 6:57 AM  
Blogger Unknown said...

I enjoyed over read your blog post. Your blog have nice information , I got good idas from this amazing blog .I am always searching like this type blog post. I hope I will see again...
KSEEB Board 12th result publish in puc result - http://puc-results.in/ , puc result 2017 - http://pucresult.co.in/ , pue.kar.nic.in - http://pue-kar-nic.in/

February 20, 2017 at 12:43 PM  
Blogger Unknown said...

This is nice and amazing information. Thanks for sharing keep it up.

KSEEB announce Karnataka 10th result 2017 on sslc result 2017 karnataka - http://karnatakasslcresults.in/
CBSE Board relese 10th and 12th cbse results on cbse 10th result - http://cbse10thresult2017nic.com/

February 20, 2017 at 12:49 PM  
Blogger Unknown said...

Kerala, Karnataka and Tamilnadu 10th result named as sslc result, that here you can find it. - https://sslc-result-nic.in/
Kerala Board 10th examination result notifications here at sslc result 2017 kerala - http://keralasslcresult2017.in/

TN Board release 10th result here on sslc result 2017 tamilnadu - http://tn-sslcresult.in/
Maharashtra Board publishing 10th result and 12th here ssc result 2017 maharashtra - http://mahsscresult.in/

February 20, 2017 at 12:51 PM  
Blogger Karthik Jessie said...

AP Exam Results is the best Ap Inter 2nd year results 2017

March 5, 2017 at 11:50 PM  
Blogger Unknown said...

Here you can get the complete information about Life Insurance policies. For more click here
Life Insurance

March 28, 2017 at 1:15 AM  
Blogger Unknown said...

Click here to Get airtel digital TV monthly packs and enjoy your favorite tv channels.
airtel dth

March 28, 2017 at 8:23 AM  
Blogger Unknown said...

Click here for more information about current silver price in chennai.
silver price in chennai

April 7, 2017 at 3:18 AM  
Blogger Unknown said...

Apple TV is one of the great and best devices for media consumptions. Here all details regarding Kodi installation on apple Tv are provided. Click here
Kodi Apple TV

April 8, 2017 at 5:38 AM  
Blogger Unknown said...

Get information about Passport Police Verification Process And Status Pre-Police Verification.
Go here

April 13, 2017 at 3:50 AM  
Blogger Unknown said...

SSC result 2017
SSC result 2017

April 13, 2017 at 4:33 AM  
Blogger OnlineGovernmentJobs said...

On April 17th, 2017 there will be announces TS Junior Intermediate Result 2017. Students can check and download TS Junior Intermediate Result 2017 here also.

April 14, 2017 at 9:53 AM  
Blogger nikky said...

TN Board is going to declare Tamilnadu SSLC Result today. Students can check the results at official website of tnresults.nic.in.

May 12, 2017 at 12:53 AM  
Blogger amrutha said...

Are you searching for best 4k television? Here is it

May 16, 2017 at 6:29 AM  
Blogger Unknown said...

Check the full list of Whirlpool refrigerators / fridges in India. Compare prices and buy the best refrigerator for your home
Know more

July 17, 2017 at 1:04 AM  
Blogger Karthik Jessie said...

Direct Link to fill the application form of DRDO Recruitment 2017

Apply Online Punjab and Haryana High Court Clerk Recruitment 2017

September 5, 2017 at 8:24 AM  
Blogger Unknown said...

Thank you for sharing.Click here to get the details about govt jobs after diploma

September 6, 2017 at 6:49 AM  
Blogger Unknown said...

Nice webpage. Click here for latest govt jobs

September 7, 2017 at 7:04 AM  
Blogger rahil khan said...

You can get the all latest JNTU updates at here

November 3, 2017 at 7:28 AM  
Blogger sss digital marketing said...

Best Digital Marketing Agency

Great Information, Thanks for sharing

January 14, 2018 at 4:04 AM  
Blogger sss digital marketing said...

Best Digital Marketing companyTirupati
Great Information, Thanks for sharing

January 14, 2018 at 4:05 AM  
Blogger Unknown said...

This gives the details of all exams resultsExam ResultsPlease check for exam results

Complete information regarding all upcoming exam time tableTime TablePlease go thru the link

This link will gives you all new exam hall ticket/admission cardAdmit CardPlease click on this link

January 31, 2018 at 4:33 AM  
Blogger Unknown said...

BMTC Conductor Driver Result

HBSE 10th Class Result

PSPCL JE Result

Delhi TIS Hazari JJA Result

Rajasthan Police Admit Card

Rajasthan Police Answer Key

February 13, 2018 at 6:39 AM  
Blogger Unknown said...

Cool stuff you have got and you keep update all of us.
Hbse 10th result

February 23, 2018 at 3:23 PM  
Anonymous Anonymous said...

Thanks for the nice posting
SEO Service in Calicut
Hovato is a team of SEO professionals who worked on consumer products that reached millions of users.
SEO Service in Calicut

November 26, 2018 at 5:48 PM  
Blogger Railway Results said...

Looking For RRB Bhubaneshwar Group D Result? Look no more. Here, we are, providing the all RRB Result, may it be Group D, ALP, and RPF right, at one place at railwayresult.in. So, keep yourself updated with RRB Result.

November 28, 2018 at 6:18 AM  
Blogger Unknown said...

Thanks for the nice posting
Healthcare billing
Medisweans shows the best medical or dental billing services and claims for the physicians to ease their job with an excellent software by Sweans
Healthcare billing

December 10, 2018 at 7:08 AM  
Blogger karan singh said...

.
.
.
.

December 14, 2018 at 7:44 AM  
Blogger Harsh008 said...

Amazing!!! I like this website so much it’s really awesome. I have also gone through your other posts too and they are also very much appreciate able and I’m just waiting for your next update to come as I like all your posts…

Happy New Year Images 2019
Happy New Year Greetings 2019
New Year Background 2019
Funny New Year Quotes 2019
Happy New Year Clipart 2019

December 28, 2018 at 4:30 AM  
Blogger Harsh008 said...

you are truly a good webmaster. The web site loading pace is incredible. It kind of feels that you are doing any distinctive trick. Also, The contents are masterwork. you’ve performed a great activity on this subject!

Happy New Year Images 2019

New Year Poem 2019

New Year Background 2019

Happy New Year Greetings 2019

Happy New Year Wallpaper 2019

Happy New Year Messages 2019

December 28, 2018 at 4:31 AM  
Blogger Anbarasan14 said...

This is an awesome post. Kindly do share more post in this kinds.

Top Education Franchise In India
Language School Franchise
English Language School Franchise
Franchise In Education Sector
Best Education Franchise In India
Franchise Business In India
Education Franchise India

January 4, 2019 at 2:16 AM  
Blogger Unknown said...

Nice article thanks
MBA Essay Writing Support
Sample mba essays

January 6, 2019 at 3:11 AM  
Blogger liza said...


Very enjoyable to visit this blog and find something exciting and amazing.
visit our web

March 4, 2019 at 9:14 AM  
Blogger liza said...


Very enjoyable to visit this blog and find something exciting and amazing.
site...

March 4, 2019 at 9:14 AM  
Blogger liza said...


Very enjoyable to visit this blog and find something exciting and amazing.
site...

March 4, 2019 at 9:29 AM  
Blogger rohit008 said...

Amazing!!! I like this website so much it’s really awesome. I have also gone through your other posts too and they are also very much appreciate able and I’m just waiting for your next update to come as I like all your posts…
Good Morning Quotes 2019 With hd Images
Good Morning Quotes 2019 For Whatsapp
Good Morning Quotes 2019 In English
Good Morning Quotes 2019 For BF

March 8, 2019 at 6:08 AM  
Blogger cdcdcdcd said...

read this above post its very greatful for me thanks sharing this post ,great post.
Best Ice Fishing Gloves Best Ice Fishing Gloves Best Ice Fishing Gloves


March 16, 2019 at 3:27 AM  
Blogger UNKNOWN said...

download fmwhatsapp
fmwhatsapp for pc
fmwhatsapp for mac

March 28, 2019 at 3:23 PM  
Blogger neha devi said...

uvoffer- if you are searching for free unlimted tricks then visit now on Uvoffer.com and get unlimited offers and informations.
film ka naam whatsapp puzzle answer film ka naam whatsapp puzzle

April 6, 2019 at 1:46 AM  
Blogger Annonymous said...

Hello here are some fresh
whatsapp group links Must check them out :D

April 16, 2019 at 6:05 AM  
Blogger Fasts News said...

Amazing WEbsite

토토사이트

July 23, 2019 at 2:29 PM  
Blogger Destiny Solutions LLP said...

Quickbooks Accounting Software

August 19, 2019 at 1:20 AM  
Blogger salman said...

website
website
website
website
website
website

September 18, 2019 at 7:50 AM  
Blogger Gurvinder sir said...

Nice post. Thanks for sharing! I want people to know just how good this information is in your article. It’s interesting content and Great work.
nielit ccc admit card download 2020

January 27, 2020 at 10:30 PM  
Blogger Rose said...

Thanks for your useful information..
Web Design And

Development Company In Bangalore
| Web Design And Development Company Bangalore | Web Design Company In Bangalore | Web Designing Company Bangalore

January 30, 2020 at 6:04 AM  
Blogger Anurag Srivastava said...

I m Really looking forward to read more. Your site is very helpful for us.....Candidates who are aspiring to find Latest vacancies 2020 Sarkari Job openings in India can apply to all the vacancies listed in this page.

February 10, 2020 at 6:33 AM  
Blogger Vikas Kumar said...

thank you for this wonderful article you can check the lateset career updates

February 12, 2020 at 8:15 AM  
Blogger Vikas Kumar said...

Very nicely done. You can apply for Powergrid Jobs

February 12, 2020 at 8:16 AM  
Blogger Vikas Kumar said...

Nice post. Thanks for sharing! you can grab the Zivame Coupons

February 12, 2020 at 8:17 AM  
Blogger sureshshetty said...

Thank for this blog is more informative step by step and useful content. I here by attached my site would you see this blog .

7 tips to start a career in digital marketing

“Digital marketing is the marketing of product or service using digital technologies, mainly on the Internet, but also including mobile phones, display advertising, and any other digital medium”. This is the definition that you would get when you search for the term “Digital marketing” in google. Let’s give out a simpler explanation by saying, “the form of marketing, using the internet and technologies like phones, computer etc”.

we have offered to the advanced syllabus course digital marketing for available join now

more details click the link now

https://www.webdschool.com/digital-marketing-course-in-chennai.html

February 22, 2020 at 6:09 AM  
Blogger sureshshetty said...

Amazing blog very nice.

Web designing trends in 2020

When we look into the trends, everything which is ruling today’s world was once a start up and slowly begun getting into. But Now they have literally transformed our lives on a tremendous note. To name a few, Facebook, Whats App, Twitter can be a promising proof for such a transformation and have a true impact on the digital world.

we have offered to the advanced syllabus course web design and development for available join now

more details click the link now

https://www.webdschool.com/web-development-course-in-chennai.html

February 22, 2020 at 6:10 AM  
Blogger Urban Dezire Official said...

Hey Nice Blog Post Please Check Out This Link for purchase
Leather Mens Gym Bags for your loved ones.

February 28, 2020 at 10:11 PM  
Blogger mubarik said...

Your Website is very good, Your Website impressed us a lot, We have liked your website very much.
We have also created a website of Android App that you can see it.
http://damodapk.com/

April 3, 2020 at 1:21 PM  
Blogger Ruhi Sukhla said...

Your site is truly cool and this is an incredible rousing article.

Uniraj BA final year result

June 19, 2020 at 6:33 AM  
Blogger Rose said...

Thanks for your useful information..
Best SEO Company in Bangalore | Best SEO Services Company In Bangalore | SEO Services In Bangalore | SEO Agency In Bangalore | SEO Services Company In Bangalore

June 24, 2020 at 3:31 AM  
Blogger SUTAPA said...

সন্তানের মা হলে কি ভালোবাসা বারণ
A letter to my love
অসম্পূর্ণ ভালোবাসা | ছোঁয়া লেগেছিল মাএ
Love story of a single mother kolkata
An Affair can’t be Wrong Every Time escorts
একাকীত্ব না ভালোবাসা kolkata escorts

December 30, 2020 at 9:03 AM  
Blogger Mahawar Alloys said...

Angle traders in mandigobindgarh
TMT Bar traders in mandigobindgarh
Channels traders in mandigobindgarh
Beam traders in mandigobindgarh
Flat Bars traders in mandigobindgarh
Sheets Plates traders in mandigobindgarh
Galvanised sheet traders in mandigobindgarh
Pipeline traders in mandigobindgarh
Rail traders in mandigobindgarh
Binding traders in mandigobindgarh

January 6, 2021 at 12:50 AM  
Blogger Prashant Baghel said...

How to use jio phone sim in other smartphone
Online Bina otp ke call details kaise nikale
Mobile se google ka gmail account kaise delete kare
kgf chapter 2 full movie in hindi download
Gmail par dusra account kaise login kare
Gmail par contact kaise save karte hai
Mobile And Computer Par Gmail Se Message Kaise Bhejte Hai
Jio sim number ki incoming and outgoing call details kaise nikale
Youtube par short video kaise banaye full guide 2021
Bahubali 2 full movie in hindi hd 1080p download

January 30, 2021 at 8:38 AM  
Blogger shaun said...

I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up..
RPL Kits

February 15, 2021 at 7:08 AM  
Blogger Plumbing & HVAC Services San Diego said...

Compre documentos en línea, documentos originales y registrados.
Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

Comprar permiso de residencia,
permiso de residenciareal y falso en línea,
Compre licencia de conducir en línea,
Compre una licencia de conducir española falsa en línea,
Comprar tarjeta de identificación,
Licencia de conducir real y falsa,
Compre pasaporte real en línea,

Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
Address: 56 Guild Street, London, EC4A 3WU (UK)
Email: contact@permisodeespana.com
WhatsApp: +443455280186

April 25, 2021 at 3:34 PM  
Blogger Plumbing & HVAC Services San Diego said...

Compre documentos en línea, documentos originales y registrados.
Acerca de Permisodeespana, algunos dicen que somos los solucionadores de problemas, mientras que otros se refieren a nosotros como vendedores de soluciones. Contamos con cientos de clientes satisfechos a nivel mundial. Hacemos documentos falsos autorizados y aprobados como Permiso de Residencia Español, DNI, Pasaporte Español y Licencia de Conducir Española. Somos los fabricantes y proveedores de primer nivel de estos documentos, reconocidos a nivel mundial.

Comprar permiso de residencia,
permiso de residenciareal y falso en línea,
Compre licencia de conducir en línea,
Compre una licencia de conducir española falsa en línea,
Comprar tarjeta de identificación,
Licencia de conducir real y falsa,
Compre pasaporte real en línea,

Visit Here fpr more information. :- https://permisodeespana.com/licencia-de-conducir-espanola/
Address: 56 Guild Street, London, EC4A 3WU (UK)
Email: contact@permisodeespana.com
WhatsApp: +443455280186

April 25, 2021 at 3:36 PM  
Blogger P K said...

hello dear
Your content is very much appreciated you have represented it correctly so thanks.
If you intrested in computer Science so please check and read something new.

computer Science Courses

August 15, 2021 at 9:38 AM  
Blogger UNIQUE ACADEMY said...

UNIQUE ACADEMY FOR COMMERCE provides FREE CSEET Video Lectures to All the Students on its YouTube Channel and UNIQUE ACADEMY Website
cs executive
UNIQUE ACADEMY

August 27, 2021 at 10:58 PM  
Blogger best said...

offers amazon is online store offering most popular Mobile phones, Cameras, Electronic Gadgets, Home Appliances, Apparels, Helmets, etc
online shopping

November 12, 2021 at 10:26 PM  
Blogger George said...

There Are Many Complaints About XM REVIEW Broker In The Internet But You Should Read This Review Before Investing Your Money With Them. We Have Personally Tested XM Fx And Found It To Be A Scam, Avoid Them At All Costs!

November 17, 2021 at 1:00 AM  
Blogger Juliana petar said...

AVATRADE REVIEW If You Are A Beginner, Check Out Our Guide On How To Open An Account With AVATRADE . They Offer Copy Trading Where You Can Copy The Trades Of Successful Traders.

November 18, 2021 at 2:52 AM  
Blogger Peter Schiff said...

AVATRADE REVIEW Review - Find Out Everything About This Forex Broker. Read Our Detailed Fx Choice Review And Make Sure If This Broker Is For You. We Scrutinized The Broker And The Trading Conditions Thoroughly.

December 1, 2021 at 1:19 AM  
Blogger Oliver said...

Forex Broker USA Best Forex Brokers For Your Forex Trading And Fx. The Profanity Review And Forex Today Reviews The Forex Brokers And Provides The Best Fx Ratings And Reviews.

January 4, 2022 at 2:27 AM  
Blogger Unknown said...

packers and movers in jaipur is the best packers and movers firm in Jaipur. During the shifting time, it requires a professional and expert company. We are able to give household shifting, office shifting, car transportation, Loading and Unloading, office relocation, and Local shifting these are the services we provide you in a better form by others. Before hiring us you can check our company profile and also take 3 ESTIMATED MOVING QUOTES FREE!!

January 14, 2022 at 10:59 AM  
Blogger Unknown said...

Express Cargo packers and movers in chennai may be a Fashionable commercial activity Done Via Numerous Corporations that permits You To...

February 12, 2022 at 12:17 PM  
Blogger abc said...

Do you believe in long term investement . One of the option of doing investement is by investing in Crypto currencies. You can invest in Fudxcoin company that deals in the selling and purchasing of Crypto Currency. It is a reliable company. One need not doubt in investing in it as i have also bought crypto currency from it and feeling very satisfied with their services.
crypto currency block chain technology



March 14, 2022 at 10:28 PM  
Blogger Joseph Vijay said...

Much obliged for sharing this brilliant substance. its extremely fascinating. Numerous web journals I see these days don't actually give whatever pulls in others however the manner in which you have plainly clarified everything it's truly awesome. There are loads of posts But your method of Writing is so Good and Knowledgeable. continue to post such helpful data and view my site too...
how to make a paper airplane eagle | how to make a boomerang airplane | the eagle paper airplane | best paper airplane design for distance and accuracy | best paper airplanes for distance and speed | what is the best paper airplane design for distance | paper airplane that flies far and straight | nakamura lock paper airplane instructions | paper airplane templates for distance | science behind paper airplanes | how to make a paper airplane that flies far and straight step by step

April 16, 2022 at 3:07 AM  
Blogger AFM Logistics said...


This piece of article is amazing. I would also like the world to know about a company which gives best quality logistics service ,ie is AFM Logistics Pvt Ltd is an international freight forwarding and customs clearing company established in Delhi. The company was constituted in 2012 and is indulged in providing complete logistics solution. The company has its own setup and wide network of agents throughout the world. International Logistics Companies In India . They are the best air cargo and ocean freight forwarding company in Delhi, India. AFM Logistics Pvt Ltd has been working as Import and Export Agent in India since 2012. They have been providing personal baggage shipping services in India for a very long time.

May 6, 2022 at 9:06 AM  
Blogger SwarnApp said...

thanku so much this infromation, Nice Article
best jewellery software jewellery accounting software swarnapp software
software for jewellers
Best Jewellery Software

November 25, 2022 at 8:22 AM  
Blogger SwarnApp said...

thanku so much this infromation, Nice Article
Jewellery ERP Software Dubai
Jewellery ERP Software Dubai

April 6, 2023 at 7:53 AM  
Blogger saipdf said...

Nice post thanks for sharing this post
Sai Satcharitra Pdf
Sai Satcharitra Telugu Pdf
Sai Satcharitra Tamil Pdf

April 23, 2023 at 1:02 AM  
Blogger Thinkerstep said...

Nice post thanks for sharing this post
Best Web Development Agency USA
Best Web Development Agency USA

June 1, 2023 at 6:57 AM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home