I am trying to generate an isoscape using IsoriX in R. Here how my data looks:
> head(dataC)
siteID long lat animalID species tissue.value
1 A -5.88 53.82 CC1_33.2/1_15 C -18.46
2 A -5.88 53.82 CL1_33.2/1_15 L -19.98
3 A -5.88 53.82 CT1_33.2/1_15 P -19.17
4 A -5.88 53.82 STA_33.2/1_15 S -18.49
5 A -5.88 53.82 MESO_33.2/1_15 M -27.05
6 B -6.03 53.41 CC1_43/3_15 C -17.11
> str(dataC)
'data.frame': 322 obs. of 6 variables:
$ siteID : Factor w/ 38 levels "A","AA","B","BB",..: 1 1 1 1 1 3 3 3 5 5 ...
$ long : num -5.88 -5.88 -5.88 -5.88 -5.88 -6.03 -6.03 -6.03 -5.87 -5.87 ...
$ lat : num 53.8 53.8 53.8 53.8 53.8 ...
$ animalID : Factor w/ 322 levels "AA1_36/8_15",..: 138 187 257 318 267 144 272 294 189 273 ...
$ species : Factor w/ 7 levels "A","C",..: 2 3 6 7 4 2 4 5 3 4 ...
$ tissue.value: num -18.5 -20 -19.2 -18.5 -27.1 ...
However, as the elevation is unknown at the sampling sites, it says it has to be extracted from a high resolution elevation raster using the function extract. However I cannot make it work...
The area I need to get on is the Irish Sea:
>map("worldHires",xlim=c(-6.7,-2.7), ylim=c(52,56), col="gray90", fill=TRUE,
myborder = 0.0001)
This is what I am typing:
## Creating Raster
>library(sp) # classes for spatial data
>library(raster) # grids, rasters
>library(lattice)
>library(latticeExtra)
>library(RColorBrewer)
>library(rasterVis) # raster visualisation
>library(maptools)
>library(rgeos)
>library(dismo)
>library(XML)
>library(rgdal)
>mymap <- gmap("England", type = "satellite", filename = "England.gmap")
>plot(mymap)
>select.area <- drawExtent()
### now click 2 times on the map to select Irish Sea
>mymap <- gmap(select.area)
>plot(mymap)
### Save the map as a file in your working directory for future use
>mymap <- gmap(select.area, filename = "IrishSea.gmap")
## Get elevation values
### Read point data, and convert them into spatial points data frame
>pointCoordinates <- read.csv(file.choose(),h=T)
>coordinates(pointCoordinates) <- ~ x + y
### Extract raster value by points
>rasValue <- extract(mymap, coordinates(pointCoordinates))
### Combine raster values with point and save as a CSV file
>combinePointValue <- cbind(pointCoordinates,rasValue)
>write.table(combinePointValue,file= "combinedPointValue.csv",
append=FALSE, sep= ",", row.names = FALSE, col.names=TRUE)
--
getData
from the raster package to get SRTM elevation data?