layar names in R worldclim

values <- extract(r,points)

df <- cbind.data.frame(coordinates(points),values)

3.78
9
Xji 95 points

                                    points &lt;- spsample(as(r@extent, 'SpatialPolygons'),n=100, type=&quot;random&quot;)    

3.78 (9 Votes)
0
4.22
9
Bobathon 90 points

                                    library(raster)
library(sp)

r &lt;- getData(&quot;worldclim&quot;,var=&quot;bio&quot;,res=10)

r &lt;- r[[c(1,12)]]
names(r) &lt;- c(&quot;Temp&quot;,&quot;Prec&quot;)

lats &lt;- c(9.093028 , 9.396111, 9.161417)
lons &lt;- c(-11.7235, -11.72975, -11.709417) 

coords &lt;- data.frame(x=lons,y=lats)

points &lt;- SpatialPoints(coords, proj4string = r@crs)

values &lt;- extract(r,points)

df &lt;- 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

4.22 (9 Votes)
0
3
1

                                    r &lt;- r[[c(1,12)]]
names(r) &lt;- c(&quot;Temp&quot;,&quot;Prec&quot;)

3 (1 Votes)
0
3.71
7

                                    library(raster)
library(sp)

r &lt;- getData(&quot;worldclim&quot;,var=&quot;bio&quot;,res=10)

3.71 (7 Votes)
0
4.67
3
Nearlife 75 points

                                    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)

4.67 (3 Votes)
0
Are there any code examples left?
New code examples in category R
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source