azvoleff / gfcanalysis Goto Github PK
View Code? Open in Web Editor NEWTools for working with Hansen et al. Global Forest Change dataset
Tools for working with Hansen et al. Global Forest Change dataset
I'm trying to run a pretty straightforward implementation of this package, but have run into a problem trying to mosaic multiple tiles in extract_gfc()
. I can successfully download the files, but once I get to that command, it immediately throws the error below. Any help with this would be much appreciated.
library(dplyr)
library(gfcanalysis)
library(raster)
library(rgdal)
library(rnaturalearth)
# making a function for coordinates() w/in a pipe
coordinates_iP = function(spdf){
coordinates(spdf) = ~long+lat
return(spdf)
}
# creating extent
df = expand.grid(data.frame(lat = c(3, 10), long = c(-125,-75)))
spdf = coordinates_iP(df)
# getting study area polygon
master = ne_countries(type = 'countries', scale = 'small') %>%
crop(spdf) %>%
aggregate() %>%
as('SpatialPolygonsDataFrame')
# get tile names
tiles = calc_gfc_tiles(master)
# download tiles
download_tiles(tiles, "~/Desktop/tiles")
# moasic and save tiles
gfc_data <- extract_gfc(master, "~/Desktop/tiles", filename='gfc_extract.tif')
And the error...
Error in .local(x, y, ...) : extents do not overlap
Hi there,
Thank you so much for providing this package, which has saved us tons of time already. With the 2018 data now out, we were wondering if there's an easy way to include it. Very happy to do this in a pull request as well, if you can give some hints on which parts of the code would have to be changed.
Thanks a lot!
This package depends on (depends, imports or suggests) raster and one or more of the retiring packages rgdal, rgeos or maptools (https://r-spatial.org/r/2022/04/12/evolution.html, https://r-spatial.org/r/2022/12/14/evolution2.html). Since raster 3.6.3
, all use of external FOSS library functionality has been transferred to terra, making the retiring packages very likely redundant. It would help greatly if you could remove dependencies on the retiring packages as soon as possible.
I have successfully used the gfcanalysis to analyze 2015 GFC data, which only provides data through 2015. I would like to use the 2017 GFC dataset which provides data through 2017. However I haven't been able to download tiles using the downloadtiles() function:
download_tiles(tilesBBS, output_folder, images = c("treecover2000", "gain", "lossyear", "datamask"), data_year = 2017)
1 tiles to download/check.
trying URL 'http://commondatastorage.googleapis.com/earthenginepartners-hansen/GFC2017/Hansen_GFC2017_treecover2000_10N_080W.tif'
Error in download.file(tile_url, local_path, mode = "wb") :
cannot open URL 'http://commondatastorage.googleapis.com/earthenginepartners-hansen/GFC2017/Hansen_GFC2017_treecover2000_10N_080W.tif'
In addition: Warning message:
In download.file(tile_url, local_path, mode = "wb") :
cannot open URL 'http://commondatastorage.googleapis.com/earthenginepartners-hansen/GFC2017/Hansen_GFC2017_treecover2000_10N_080W.tif': HTTP status was '404 Not Found'
I have also tried downloading the tiles into the working directory and extracting them with extract_gfc() for my AOI, but the program isn't able to find the files. I've also tried changing the 2017 file names to match the format of the 2015 file names, but this hasn't worked either.
Any help would be greatly appreciated - thank you!
Currently out_dir
isn't fully respected. Animations end up one folder below out_dir
if out_dir
includes the directory and basename (for example out_dir="BBS/bbs_animation"
).
A small detail.
Considering that there is no warning about the CRS to be used when providing an AOI, I think that check the overlap between the tiles and the aoi could be an option of calc_gfc_tiles().
I fact the calc_gfc_tiles() function takes the .shp and internally transform the crs to match the tiles and verify the overlap. The crs of aoi shapefile itself ramains unchanged and plot it against tiles, as suggested, is no useful without another crs transformation.
calc_pixel_areas() seems to be missing from exported functions.
> gfcanalysis::calc_pixel_areas(mygfc[[1]])
Error: 'calc_pixel_areas' is not an exported object from 'namespace:gfcanalysis'
Called from: getExportedValue(pkg, name)
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] forcats_0.5.0 stringr_1.4.0 dplyr_1.0.2 purrr_0.3.4 readr_1.4.0 tidyr_1.1.2
[7] tibble_3.0.4 ggplot2_3.3.2 tidyverse_1.3.0 sf_0.9-6 gfcanalysis_1.6.0 raster_3.4-5
[13] sp_1.4-4
loaded via a namespace (and not attached):
[1] bitops_1.0-6 fs_1.5.0 usethis_1.6.3 lubridate_1.7.9.2 devtools_2.3.2
[6] RColorBrewer_1.1-2 httr_1.4.2 rprojroot_2.0.2 tools_4.0.3 backports_1.2.0
[11] utf8_1.1.4 rgdal_1.5-18 R6_2.5.0 KernSmooth_2.23-17 rgeos_0.5-5
[16] DBI_1.1.0 colorspace_2.0-0 withr_2.3.0 tidyselect_1.1.0 prettyunits_1.1.1
[21] processx_3.4.5 compiler_4.0.3 cli_2.2.0 rvest_0.3.6 animation_2.6
[26] xml2_1.3.2 desc_1.2.0 scales_1.1.1 classInt_0.4-3 hexbin_1.28.1
[31] callr_3.5.1 digest_0.6.27 jpeg_0.1-8.1 pkgconfig_2.0.3 sessioninfo_1.1.1
[36] dbplyr_2.0.0 rlang_0.4.9 readxl_1.3.1 rstudioapi_0.13 generics_0.1.0
[41] zoo_1.8-8 jsonlite_1.7.1 RCurl_1.98-1.2 magrittr_2.0.1 geosphere_1.5-10
[46] Rcpp_1.0.5 munsell_0.5.0 fansi_0.4.1 lifecycle_0.2.0 stringi_1.5.3
[51] yaml_2.2.1 pkgbuild_1.1.0 plyr_1.8.6 grid_4.0.3 parallel_4.0.3
[56] crayon_1.3.4 rasterVis_0.49 lattice_0.20-41 haven_2.3.1 hms_0.5.3
[61] ps_1.5.0 pillar_1.4.7 codetools_0.2-16 pkgload_1.1.0 reprex_0.3.0
[66] glue_1.4.2 latticeExtra_0.6-29 remotes_2.2.0 modelr_0.1.8 png_0.1-7
[71] vctrs_0.3.5 testthat_3.0.0 cellranger_1.1.0 gtable_0.3.0 assertthat_0.2.1
[76] broom_0.7.2 e1071_1.7-4 class_7.3-17 viridisLite_0.3.0 memoise_1.1.0
[81] units_0.6-7 ellipsis_0.3.1
* DONE (gfcanalysis)
Reloading installed gfcanalysis
> gfc_data <- extract_gfc(aois, data_folder)
non finite transformation detected:
[1] 124.463577 -9.178817 Inf Inf
Warning message:
In .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, :
78 projected point(s) not finite
Error in is.projected(spgeom) :
error in evaluating the argument 'obj' in selecting a method for function 'is.projected': Error in .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, :
failure in Polygons 1 Polygon 1 points 1
I see:
checking whether package ‘gfcanalysis’ can be installed ... WARNING
Found the following significant warnings:
Warning: replacing previous import by ‘grid::unit’ when loading ‘gfcanalysis’
See ‘/private/tmp/Rtmpri6X2x/check_cran33a12e539bd0/gfcanalysis.Rcheck/00install.out’ for details.
checking DESCRIPTION meta-information ... NOTE
Malformed Description field: should contain one or more complete sentences.
Hi there! Thanks for making this excellent package - it makes accessing this fabulous data resource simple and straightforward!
One question/comment - the extract_gfc() function takes quite a long time if the area of interest is large; for example, I'm doing analysis on the scale of all of British Columbia, Canada. I realize that I'm asking the function to extract and mosaic a lot of spatial data together, so it's not surprising that this takes a long time (and is prone to making my R session crash). However, I thought I'd bring this up in case you had recommendations for how large a spatial extent/max number of tiles that you should apply this function to (and whether it is computationally better to do large areas in pieces)?
Thanks again for making this available - great work!
Hi thanks for the package! I'm getting an error on the annual_stack
function:
Error in h(simpleError(msg, call)) : error in evaluating the argument 'i' in selecting a method for function '[<-': 'data' must be of a vector type, was 'NULL'
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.