layar names in R worldclim
values <- extract(r,points)
df <- cbind.data.frame(coordinates(points),values)
3.78
9
points <- spsample(as(r@extent, 'SpatialPolygons'),n=100, type="random")
Thank you!
9
0
4.22
9
library(raster)
library(sp)
r <- getData("worldclim",var="bio",res=10)
r <- r[[c(1,12)]]
names(r) <- c("Temp","Prec")
lats <- c(9.093028 , 9.396111, 9.161417)
lons <- c(-11.7235, -11.72975, -11.709417)
coords <- data.frame(x=lons,y=lats)
points <- SpatialPoints(coords, proj4string = r@crs)
values <- extract(r,points)
df <- cbind.data.frame(coordinates(points),values)
df
x y Temp Prec
1 -11.72350 9.093028 257 2752
2 -11.72975 9.396111 257 2377
3 -11.70942 9.161417 257 2752
Thank you!
9
0
3
1
r <- r[[c(1,12)]]
names(r) <- c("Temp","Prec")
Thank you!
1
0
3.71
7
library(raster)
library(sp)
r <- getData("worldclim",var="bio",res=10)
Thank you!
7
0
4.67
3
head(df)
x y Temp Prec
1 112.95985 52.092650 -37 388
2 163.54612 85.281643 NA NA
3 30.95257 5.932434 270 950
4 64.66979 40.912583 150 150
5 -169.40479 -58.889104 NA NA
6 51.46045 54.813600 36 549
plot(r[[1]])
plot(points,add=T)
Thank you!
3
0
Are there any code examples left?
New code examples in category R
-
R 2022-03-27 14:00:12 R total line text file
-
R 2022-03-27 13:40:24 reduce ggtitle size
-
R 2022-03-23 02:05:30 r merge inner join
-
R 2022-03-21 19:20:02 combine columns in r
-
R 2022-03-16 11:05:16 ggplot box plot without outliers poins
-
R 2022-03-13 03:05:04 calculated defualt values in R function parameters
-
R 2022-03-12 21:55:01 r rename columns
-
R 2022-03-08 02:25:18 r - transform as factor
-
R 2022-03-06 02:50:06 create a dataframe with column names in r