[R-sig-Geo] Mask from raster with less RAM
Frederico Faleiro
|v|@|e|ro @end|ng |rom gm@||@com
Sat Aug 15 00:08:43 CEST 2020
Hi guys,
thank you for your help. Sometimes we really need more RAM. I got access to
a cluster with more RAM and solved the problem.
Dear Sourav, you are right, but the crop only cuts the extent of the
rasters, so I really need to use mask. In addition, my main limitation was
in generating the polygon from raster (i.e. rasterToPolygons).
Cheers!
Em qua., 12 de ago. de 2020 às 15:20, Sourav Sarkar <
sourav.sarkar using ahduni.edu.in> escreveu:
> Dear Frederico,
> With the very little experience that I have with raster data, it seems to
> me (maybe I am wrong) that `crop' is computationally easier than `mask'. If
> the crop command serves your purpose, maybe you can try:
> r2.mask <- crop(r2, pol)
>
> Kind regards,
>
> বুধ, ১২ আগস্ট, ২০২০ তারিখে ২:১৩ AM টায় এ Frederico Faleiro <
> fvfaleiro using gmail.com> লিখেছেন:
>
>> Dear all,
>>
>> I would like to generate a mask from a raster, but my workflow needs a lot
>> of RAM to process big rasters. I need this polygon mask to use in
>> another's
>> rasters.
>> Do you know another approach that needs less RAM?
>>
>> # reproducible example
>> library(raster)
>> # read data to create mask
>> r <- raster(system.file("external/test.grd", package="raster"))
>> r[!is.na(r)] <- 1
>> pol <- rasterToPolygons(r, dissolve = T) # a lot of RAM to process the
>> data
>> # apply the mask in another raster
>> r2 <- raster(extent(r), res(r))
>> r2[ ] <- 1
>> r2.mask <- mask(r2, pol)
>>
>> Cheers!
>>
>> [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo using r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
> --
> Sourav Sarkar,
> Assistant Professor,
> School of Arts and Sciences,
> Ahmedabad University
>
--
Frederico Faleiro
Postdoctoral Researcher in the INCT-EECBio (https://www.eecbio.ufg.br/)
Department of Ecology | Institute of Biological Science | Federal
University of Goiás | Brazil
RG: https://www.researchgate.net/profile/Frederico_Faleiro
CV: http://lattes.cnpq.br/4926404840659003
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list