Spatial question

12 views
Skip to first unread message

Leila Brook

unread,
Aug 30, 2012, 10:37:34 PM8/30/12
to tropi...@googlegroups.com

Hi Spatial ecologists,

I have a spatial R question I've been struggling with this morning and Lauren's email reminded me that this might be a way to solve it!

 

I have a DEM 9s asci file and a dataframe which contains my GPS data, including estimates of coordinates and altitude.

 

I want to find the difference between the altitude value of the DEM and the altitude calculated by the GPS at each datapoint.

 

I feel like I should be able to get a function to do this, but I'm not sure how to extract the DEM value at each of the coordinates.

 

Does anyone know an easy way to extract this info from the DEM asci?

 

Any tips would be really appreciated!
Leila

Lauren Hodgson

unread,
Aug 31, 2012, 2:05:11 AM8/31/12
to tropi...@googlegroups.com
library(SDMTools)
DEMasc=read.asc('/file path of DEM.asc') #read in your ascii

GPSdata=read.csv('/file path of gpc data.csv',as.is=TRUE) #read in your csv
GPSdata$DEMvalues=extract.data(cbind(GPSdata$lon,GPSdata$lat),DEMasc)
#extracts the altitude from the DEM at the lat and lon given by your
GPS... note: chnage $lon and $lat to whatever your lon and lat columns
is are actually named.

The difference should simply be DEM altitude minus GPS altitude.
> --
> An R group for questions, tips and tricks relevant to spatial ecology and
> climate change.
> All R questions welcome.
> ---
> You received this message because you are subscribed to the Google Groups
> "Tropical R" group.
> To post to this group, send an email to tropi...@googlegroups.com.
> To unsubscribe from this group, send email to
> tropical-r+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Stewart Macdonald

unread,
Aug 30, 2012, 10:41:10 PM8/30/12
to tropi...@googlegroups.com
Off the top of my head...

extract.data() in the SDMTools package should do it:

http://www.rforge.net/doc/packages/SDMTools/html/extract.data.html


Stewart

Stewart Macdonald

unread,
Sep 1, 2012, 2:11:33 AM9/1/12
to <tropical-r@googlegroups.com>
Timely delivery, Google Groups.


Stewart

Lauren Hodgson

unread,
Sep 1, 2012, 11:56:02 PM9/1/12
to tropi...@googlegroups.com
It thought you were a spambot. I've had my suspicions....
Reply all
Reply to author
Forward
0 new messages