afsc-gap-products / coldpool

Cold pool area and temperature data products for the eastern Bering Sea from NOAA/AFSC/RACE Groundfish Assessment Program's summer trawl surveys
Other
9 stars 1 forks source link

unable to re-project coldpool rasterbricks when showing NBS and EBS together #40

Closed EmilyMarkowitz-NOAA closed 1 year ago

EmilyMarkowitz-NOAA commented 1 year ago

The problem:

For the BS data report, we plot surface and bottom temperatures over the previous few years.

With previous version of R (R version 4.2.0 (2022-04-22 ucrt); Platform: x86_64-w64-mingw32/x64 (64-bit); Running under: Windows 10 x64 (build 19045) and likely a previous version of raster and rdgal), this script would work fine. I just updated to the latest and greatest version of R (session info in Fig 1) and the script no longer works, returning this error message (it says warning, but acts as error): Warning: input and ouput crs are the sameWarning: input and ouput crs are the sameError in compareRaster(c(x, rasters)) : different extent.

Fig 1: Latest and greatest session info: image

The short term fix:

Using the Fig 2 session info, we were able to get the figures to work using the fix below. There were a few warnings and comments, but they didn't interrupt the run (Fig 2):

Replace lines 589 raster::projectRaster(raster::projectExtent(nbs_no_2018, crs = raster::crs(coldpool::nbs_ebs_surface_temperature)) and 607 raster::projectRaster(raster::projectExtent(nbs_no_2018, crs = raster::crs(coldpool::nbs_ebs_bottom_temperature)) with raster::projectRaster(raster::projectExtent(nbs_no_2018, crs = "EPSG:3338"))

Fig 2: After applying the above code change, the code returned the figures with these warnings and comments: image

Long-term concern: problem with raster dropping rgdal?

Not really a {coldpool} package problem?

sean-rohan-NOAA commented 1 year ago

The replacement for L607 should be:

raster::projectRaster(raster::projectExtent(nbs_no_2018, crs = raster::crs(coldpool::nbs_ebs_bottom_temperature)))

The CRS is EPSG:3338 but doing so would hard-code the CRS.

sean-rohan-NOAA commented 1 year ago

Closing this issue because it isn't specifically an issue with the coldpool package. It appears to be an issue with how projectRaster handles extents and coordinate reference systems in raster objects after raster 3.6.3.

As of raster 3.6.3, past functionality provided by rgdal is now handled by the terra package.