[R-sig-Geo] Problems with mask (raster)

Jaime R. Garcia Marquez jaime.garcia at uni-bonn.de
Fri Oct 15 13:10:55 CEST 2010


Hola Manuel,

Regarding the values of the .bil files I was dealing with 
that also sometime ago.

I found this link in a forum who helped me understand what 
is going on with these files:

http://pvanb.wordpress.com/2010/02/06/importing-worldclim-climate-bil-datalayers-in-grass-gis/

So I wrote in R something like this to get the right 
values:

library(raster)
bio <- raster("bio1_23.bil")
ind <- which(bio[] > 32767)
bio[ind] <- bio[ind] - (65535+1)
bio[bio[] == -9999] <- NA
bio
plot(bio)

Hope this helps.

Saludos, pura vida

Jaime

On Thu, 14 Oct 2010 16:17:25 -0600
  Manuel Spínola <mspinola10 at gmail.com> wrote:
>  Thank you very much Robert,
> 
> Now I have this error:
> 
> > me <- maxent(bio1res, arb)
> Error en .local(x, p, ...) :
>   more than half of the presence points have NA 
>predictor values
> 
> It could be related to the raster "bio1res"?  The origin 
>of this file is 
> .bil files.  Which is the best file format to work with 
>bioclim data?
> The plot(bio1res) display with a legend with values from 
>0 to 50000 and 
> the raster is for temperature.
> 
> bio1res
> class       : RasterLayer
> filename    :
> nrow        : 382
> ncol        : 407
> ncell       : 155474
> min value   : 47
> max value   : 55537
> projection  : NA
> xmin        : -85.95
> xmax        : -82.55833
> ymin        : 8.041667
> ymax        : 11.225
> xres        : 0.008333333
> yres        : 0.008333333
> 
> Best,
> 
> Manuel
> 
> 
> On 14/10/2010 02:44 p.m., Robert J. Hijmans wrote:
>> I think it should be:
>>
>> res<- mask(bio1cr, crmask)
>>
>> On Thu, Oct 14, 2010 at 1:22 PM, Manuel 
>>Spínola<mspinola10 at gmail.com>  wrote:
>>>   Dear list members,
>>>
>>> I am working with bioclim variables to model species 
>>>distribution.
>>> The files downloaded from Worldclim.org are generic 
>>>raster files (.bil)
>>> I transform this files to raster:
>>>
>>> bio1<- raster("bio1_23.bil")
>>>
>>> cr = readOGR(dsn="C:/ProyectoRespacial/EvalHab_reporte",
>>> layer="Cr_wgs84_meso")
>>>
>>> bio1cr<- crop(bio1, cr)
>>> crmask<- polygonsToRaster(cr, bio1cr)
>>> res<- mask(bio1, crmask)
>>> Error en compare(x, mask) : Different bounding box
>>>
>>> plot(bio1cr) the scale legend shows numbers from 0 to 
>>>55000
>>>
>>> Best,
>>>
>>> Manuel
>>>
>>>
>>> --
>>> *Manuel Spínola, Ph.D.*
>>> Instituto Internacional en Conservación y Manejo de Vida 
>>>Silvestre
>>> Universidad Nacional
>>> Apartado 1350-3000
>>> Heredia
>>> COSTA RICA
>>> mspinola at una.ac.cr
>>> mspinola10 at gmail.com
>>> Teléfono: (506) 2277-3598
>>> Fax: (506) 2237-7036
>>> Personal website: Lobito de río
>>> <https://sites.google.com/site/lobitoderio/>
>>> Institutional website: 
>>>ICOMVIS<http://www.icomvis.una.ac.cr/>
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>>
>>> _______________________________________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at stat.math.ethz.ch
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>>
>>>
> 
> 
> -- 
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida 
>Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola at una.ac.cr
> mspinola10 at gmail.com
> Teléfono: (506) 2277-3598
>Fax: (506) 2237-7036
> Personal website: Lobito de río 
> <https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS 
><http://www.icomvis.una.ac.cr/>
> 
> 	[[alternative HTML version deleted]]
>



More information about the R-sig-Geo mailing list