extracting 19 bioclim variables from single Tiff file of SSP scenerios

79 views
Skip to first unread message

shawkat sohel

unread,
Apr 11, 2024, 8:56:22 PMApr 11
to Maxent
Hi,
Good day. Need suggestions regarding new worldclim scenario SSP data. Future projections have single TIF file with variables saved as bands within this file. How can I can extract them quickly in R? Please share some brief code?
Thank you.

Kind regards,
Sohel

Fabio David Alabar

unread,
Apr 11, 2024, 9:03:10 PMApr 11
to Maxent
Hola, 
por ejemplo para bio01

bio01<- raster("archivo_de_las_19_variables.tif", band=1)
espero que sirva.
SALUDOS

FABIO DAVID ALABAR





De: max...@googlegroups.com <max...@googlegroups.com> en nombre de shawkat sohel <soh...@gmail.com>
Enviado: jueves, 11 de abril de 2024 21:56
Para: Maxent <max...@googlegroups.com>
Asunto: [maxent] extracting 19 bioclim variables from single Tiff file of SSP scenerios
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/9e2b27b4-3fba-4d35-b70d-c117ac63d2e8n%40googlegroups.com.

shawkat sohel

unread,
Apr 11, 2024, 9:24:46 PMApr 11
to max...@googlegroups.com
Hi, thank you. I want to extract all the bioclim variables together, not separately. Can you please share the codes?

Thank you.

You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/Um2o-5fAqMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/LV8PR84MB36329AB7FEE30857DF3BF9B9AC042%40LV8PR84MB3632.NAMPRD84.PROD.OUTLOOK.COM.

Bede-Fazekas Ákos

unread,
Apr 12, 2024, 2:54:16 AMApr 12
to max...@googlegroups.com
Dear Sohel,

This will read all BCV layers in a single RasterStack:
library(raster)
all_bcvs <- stack("filename.tif")

If you want to save each layers to separate geoTiff files, then something like this will do the job:
for (i in 1:19){
    writeRaster(x = all_bcvs[[i]], filename = paste0("bcv_", as.character(i)))
}

HTH,
Ákos
____________
Ákos Bede-Fazekas
Centre for Ecological Research, Hungary

Gebreyohannes Zenebe

unread,
Apr 12, 2024, 3:26:52 AMApr 12
to max...@googlegroups.com
Hi Sohel,
Please use the script below.
God luck!
library(terra)
bioclim<-rast("D:/--/--/-.tif")
setwd("D:/--/--/--/")
for (i in 1:length(bioclim)) {
writeRaster(bioclim[[1]], names(bioclim[[i]]), format='GTiff')
}


--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/9e2b27b4-3fba-4d35-b70d-c117ac63d2e8n%40googlegroups.com.


--
With kind regards,

Gebreyohannes Zenebe
MSc. in Geo-Information and Earth Observation Science for Natural Resources Management
Mobile: +251914757067
alternative email: g.ze...@seefconsult.com




Gebreyohannes Zenebe

unread,
Apr 12, 2024, 4:20:29 AMApr 12
to max...@googlegroups.com
Sorry Sohel,
Use this one.
library(terra)
bioclim<-rast("D:/--/--/-.tif")
setwd("D:/--/--/--/")
for (i in 1:length(bioclim)) {
terra::writeRaster(bioclim, paste0(names(bioclim), ".tif"))
}


On Fri, Apr 12, 2024 at 3:56 AM shawkat sohel <soh...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "Maxent" group.
To unsubscribe from this group and stop receiving emails from it, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/9e2b27b4-3fba-4d35-b70d-c117ac63d2e8n%40googlegroups.com.

shawkat sohel

unread,
Apr 12, 2024, 6:10:20 AMApr 12
to max...@googlegroups.com
Hi All,
Thank you so much for your prompt reply. I found a way to extract bioclim variables from multiband tiff files using QGIS. 
Regarding the R codes, I was not able to install the GDAL and gdalUtils packages on my laptop (showing continuous error), which is why I used QGIS. 

Thank you.

You received this message because you are subscribed to a topic in the Google Groups "Maxent" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maxent/Um2o-5fAqMA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maxent+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/maxent/CA%2BPW5saUSHKdryhc5LRr%3D6hC5pMaaP76rpX%3DerGroMOhg2EtBw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages