Re: [R-sig-Geo] raster: crop error ('nrows > 0 is not TRUE')

2016-10-03 Thread Dominik Schneider
Isn't the southern border of your boundary shapefile outside the extent of
your raster? hence there are no rows to extract.

On Mon, Oct 3, 2016 at 7:45 AM, Mauricio Zambrano Bigiarini <
mauricio.zambr...@ufrontera.cl> wrote:

> Dear list,
>
> I'm applying the 'crop' command of the raster pacakge to subset a
> RasterStack ('r') with a SpatialPolygonsDataFrame ('boundary'):
>
> raster.crop <- crop(r, boundary, snap="out")
>
> and what I get is:
>
> Error: nrows > 0 is not TRUE
>
>
> The summary of the two previous objects are:
>
> > r
> class   : RasterStack
> dimensions  : 666, 211, 140526, 8  (nrow, ncol, ncell, nlayers)
> resolution  : 0.05, 0.05  (x, y)
> extent  : -76.3, -65.75, -50, -16.7  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
> +towgs84=0,0,0
> names   : Year.2003, Year.2004, Year.2005, Year.2006, Year.2007,
> Year.2008, Year.2009, Year.2010
> min values  : 0, 0, 0, 0, 0,
>   0, 0, 0
> max values  :844.79,706.53,616.73,888.75,701.53,
>  853.47,642.07,986.31
>
>
> > boundary
> class   : SpatialPolygonsDataFrame
> features: 16
> extent  : -75.693, -66.419, -55.914, -17.498  (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
> +towgs84=0,0,0
> variables   : 1
> names   : NOM_REG
> min values  :   1
> max values  :   9
>
> the previous 'crop' command worked perfectly with a different
> RasterStack object, with a similar spatial extent, and I don't now
> what is wrong here.
>
>
> The output of my sessionInfo() is:
>
> sessionInfo()
> R version 3.3.1 (2016-06-21)
> Platform: x86_64-pc-linux-gnu (64-bit)
> Running under: Ubuntu 14.04.2 LTS
>
> locale:
>  [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
> LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
> LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_GB.UTF-8
> LC_PAPER=en_US.UTF-8   LC_NAME=C
>  [9] LC_ADDRESS=C   LC_TELEPHONE=C
> LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
>
> other attached packages:
>  [1] colorspace_1.2-6reshape2_1.4.1  rasterVis_0.40
> latticeExtra_0.6-28 RColorBrewer_1.1-2  lattice_0.20-34
> rgdal_1.1-10hydroGOF_0.3-8-7hydroTSM_0.4-8  xts_0.9-7
>  zoo_1.7-13
> [12] raster_2.5-8sp_1.2-3
>
> loaded via a namespace (and not attached):
>  [1] Rcpp_0.12.6   magrittr_1.5  maptools_0.8-39
> viridisLite_0.1.3 FNN_1.1   stringr_1.0.0 plyr_1.8.4
>  tools_3.3.1   parallel_3.3.1grid_3.3.1gstat_1.1-3
>   e1071_1.6-7
> [13] class_7.3-14  intervals_0.15.1  automap_1.0-14ncdf4_1.15
>   stringi_1.1.1 spacetime_1.1-5   reshape_0.8.5
> foreign_0.8-66hexbin_1.27.1
>
>
> Any idea about how to solve this issue is highly appreciated.
>
> Thanks in advance,
>
>
>
> Mauricio Zambrano-Bigiarini, PhD
>
> =
> Department of Civil Engineering
> Faculty of Engineering and Sciences
> Universidad de La Frontera
> PO Box 54-D, Temuco, Chile
> http://hzambran.github.io/
> =
> mailto : mauricio.zambr...@ufrontera.cl
> work-phone : +56 45 259 2812
> =
> "To accomplish great things, we must not only act,
> but also dream; not only plan, but also believe"
> (Anatole France)
> =
> Linux user #454569 -- Linux Mint user
>
> --
> La información contenida en este correo electrónico y cualquier anexo o
> respuesta relacionada, puede contener datos e información confidencial y no
> puede ser usada o difundida por personas distintas a su(s) destinatario(s).
> Si usted no es el destinatario de esta comunicación, le informamos que
> cualquier divulgación, distribución o copia de esta información constituye
> un delito conforme a la ley chilena. Si lo ha recibido por error, por favor
> borre el mensaje y todos sus anexos y notifique al remitente.
>
> ___
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[[alternative HTML version deleted]]

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

[R-sig-Geo] raster: crop error ('nrows > 0 is not TRUE')

2016-10-03 Thread Mauricio Zambrano Bigiarini
Dear list,

I'm applying the 'crop' command of the raster pacakge to subset a
RasterStack ('r') with a SpatialPolygonsDataFrame ('boundary'):

raster.crop <- crop(r, boundary, snap="out")

and what I get is:

Error: nrows > 0 is not TRUE


The summary of the two previous objects are:

> r
class   : RasterStack
dimensions  : 666, 211, 140526, 8  (nrow, ncol, ncell, nlayers)
resolution  : 0.05, 0.05  (x, y)
extent  : -76.3, -65.75, -50, -16.7  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
names   : Year.2003, Year.2004, Year.2005, Year.2006, Year.2007,
Year.2008, Year.2009, Year.2010
min values  : 0, 0, 0, 0, 0,
  0, 0, 0
max values  :844.79,706.53,616.73,888.75,701.53,
 853.47,642.07,986.31


> boundary
class   : SpatialPolygonsDataFrame
features: 16
extent  : -75.693, -66.419, -55.914, -17.498  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0
variables   : 1
names   : NOM_REG
min values  :   1
max values  :   9

the previous 'crop' command worked perfectly with a different
RasterStack object, with a similar spatial extent, and I don't now
what is wrong here.


The output of my sessionInfo() is:

sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS

locale:
 [1] LC_CTYPE=en_GB.UTF-8   LC_NUMERIC=C
LC_TIME=en_GB.UTF-8LC_COLLATE=en_GB.UTF-8
LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_GB.UTF-8
LC_PAPER=en_US.UTF-8   LC_NAME=C
 [9] LC_ADDRESS=C   LC_TELEPHONE=C
LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

other attached packages:
 [1] colorspace_1.2-6reshape2_1.4.1  rasterVis_0.40
latticeExtra_0.6-28 RColorBrewer_1.1-2  lattice_0.20-34
rgdal_1.1-10hydroGOF_0.3-8-7hydroTSM_0.4-8  xts_0.9-7
 zoo_1.7-13
[12] raster_2.5-8sp_1.2-3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.6   magrittr_1.5  maptools_0.8-39
viridisLite_0.1.3 FNN_1.1   stringr_1.0.0 plyr_1.8.4
 tools_3.3.1   parallel_3.3.1grid_3.3.1gstat_1.1-3
  e1071_1.6-7
[13] class_7.3-14  intervals_0.15.1  automap_1.0-14ncdf4_1.15
  stringi_1.1.1 spacetime_1.1-5   reshape_0.8.5
foreign_0.8-66hexbin_1.27.1


Any idea about how to solve this issue is highly appreciated.

Thanks in advance,



Mauricio Zambrano-Bigiarini, PhD

=
Department of Civil Engineering
Faculty of Engineering and Sciences
Universidad de La Frontera
PO Box 54-D, Temuco, Chile
http://hzambran.github.io/
=
mailto : mauricio.zambr...@ufrontera.cl
work-phone : +56 45 259 2812
=
"To accomplish great things, we must not only act,
but also dream; not only plan, but also believe"
(Anatole France)
=
Linux user #454569 -- Linux Mint user

-- 
La información contenida en este correo electrónico y cualquier anexo o 
respuesta relacionada, puede contener datos e información confidencial y no 
puede ser usada o difundida por personas distintas a su(s) destinatario(s). 
Si usted no es el destinatario de esta comunicación, le informamos que 
cualquier divulgación, distribución o copia de esta información constituye 
un delito conforme a la ley chilena. Si lo ha recibido por error, por favor 
borre el mensaje y todos sus anexos y notifique al remitente.

___
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo