[R-sig-Geo] Extract multiple raster but obtain NULL values
Robert J. Hijmans
r.hijmans at gmail.com
Thu Jul 18 18:22:36 CEST 2013
Diego,
To check what extract does you should look at what it returns! Your
object "rasValue" in this case.
Then it should be easy to understand that the mistake is here:
combine=cbind(points,rasValue)
You can fix it like this:
combine=cbind(coordinates(points), rasValue)
Robert
On Thu, Jul 18, 2013 at 1:36 AM, Diego Valbuena <dfvv at yahoo.com> wrote:
> Hello All,
>
> This must be a simple mistake but I'm trying to get information for few points of 10.000 raster files (TIFF) into a table. If I do it individually, I get the real values for each individual raster. But if I do it using "stack" (see below), I get the correct values only for the first raster; for the other raster files I get NULL. Would you have a suggestion to make it work (I'm using R 3.0.1)?
> Thanks, Diego
>
>
>
> library (sp)
> library (rgdal)
> library (raster)
>
> f <- list.files("folder")
>
> s <- stack(f)
>
>
> points = read.csv("points.csv")
>
> coordinates(points)= ~X+Y
>
> rasValue=extract(s, points)
>
> combine=cbind(points,rasValue)
>
>
>
>
> PS. Uploading only two raster I get this result:
>
> points2 r19830101.1 r19830101.2
> [1,] ? 0 NULL
> [2,] ? 0 NULL
> [3,] ? 0 NULL
> [4,] ? 0 NULL
> [[alternative HTML version deleted]]
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
More information about the R-sig-Geo
mailing list