Closed JosiahParry closed 3 months ago
Compare this to the output on Mac:
library(arcgis)
#> Attaching core arcgis packages:
#> → arcgisutils v0.3.0
#> → arcgislayers v0.3.0
#> → arcgisgeocode v0.1.3
#> → arcgisplaces v0.1.0
library(terra)
#> terra 1.7.71
#>
#> Attaching package: 'terra'
#>
#> The following object is masked from 'package:arcgisplaces':
#>
#> categories
bigmap.url <- 'https://di-usfsdata.img.arcgis.com/arcgis/rest/services/FIA_BIGMAP_2018_Species_Aboveground_Biomass/ImageServer'
bigmap.dataset <- arc_open(bigmap.url)
bigmap.dataset
#> <ImageServer <1 bands, 27 fields>>
#> Name: FIA_BIGMAP_2018_Species_Aboveground_Biomass
#> Description: BIGMAP Species Aboveground Biomass
#> Extent: -2911620 2933940 164760 3254760 (xmin, xmax, ymin, ymax)
#> Resolution: 30 x 30
#> CRS: 102039
#> Capabilities: Image,Metadata,Catalog,Mensuration
res <- arc_raster(
bigmap.dataset,
xmin=-2911620,
ymin=164760,
xmax=2933940,
ymax=3254760,
bbox_crs=102039
)
#> Warning in CPL_crs_from_input(x): GDAL Error 1: PROJ:
#> proj_create_from_database: crs not found
#> Warning in CPL_crs_from_input(x): GDAL Error 1: PROJ:
#> proj_create_from_database: crs not found
terra::plot(res, 1)
Created on 2024-07-23 with reprex v2.1.0
This is because the file is corrupted on Windows. Did you check if you can use the file created on the Mac on your Windows machine? And can you read the file created on Windows in ArcGIS?
The file is created by arcgis::arc_raster
(not by "terra"), and I think that it creates a corrupted file on Windows because it has this line
utils::download.file(exported_image_path, tmp, quiet = TRUE)
Where it should be
utils::download.file(exported_image_path, tmp, quiet = TRUE, mode="wb")
Fixed in the PR mentioned above
There's this reproducible issue that we're running into that appears to be related to how terra::rast() works on different OS. When using terra on windows we run into an issue that generates a broken tiff file. See the below (attached tiff file as well)
Created on 2024-07-23 with reprex v2.1.1 Tiff is in a zip file b/c thats what GitHub supports :) filec881c18754b.zip
However when running this on MacOS the TIFFFetchNormalTag**** warnings do not occur and the tiff can be plotted and read.