[R-sig-Geo] projectRaster across the antimeridian

Fischbach, Anthony afischbach at usgs.gov
Fri Jul 1 20:48:32 CEST 2016


The solution to the previous post addressing projection of rasters across
the antimeridian
(
http://r-sig-geo.2731867.n2.nabble.com/coercing-marmap-bathy-object-to-raster-spanning-the-antimeridian-td7589828.html#a7589841
)
no-longer functions
(as of 24 June 2016).

Below I offer permutations of the solution offered in the previous post,
to no avail.

Is this a bug in the raster package, or may my code be adjusted to produce
a projected raster that includes both the western and eastern hemisphere of
the original image?

-Tony

require(sp)
require(raster)
setwd('D:/Temp')
## Define projections
prj.geo<-CRS('+proj=longlat +datum=WGS84')
prj.StudyArea <- CRS("+proj=aeqd +lat_0=70 +lon_0=-170")
prj.StudyAreaPositive <- CRS("+proj=aeqd +lat_0=70 +lon_0=190")
## Download geoJPEG
Yesterday <- Sys.Date() -1
cat(URL<- format(Yesterday, '
http://lance-modis.eosdis.nasa.gov/subsets/index.php?subset=BeringSea.%Y%j.terra.721.2km.jpg'),
fill=T)
cat(DestFile<-format(Yesterday,'BeringSea.%Y%j.terra.721.2km.jpg' ,
sep=""), fill=T)##
try(ds<-download.file(url=URL, destfile=DestFile, method="libcurl", quiet =
F, mode = "wb", cacheOK = F))
## Cast as raster stack
BS.terra<-stack(DestFile)
## Assign projection
projection(BS.terra)<- prj.geo
ymax(BS.terra) <- 70
ymin(BS.terra) <- 58
xmax(BS.terra) = 360-155
xmin(BS.terra) = 360-190
## project the raster stack
(BS.terra.sa1<-projectRaster(from=BS.terra,  res=5000,
crs=prj.StudyAreaPositive, method='ngb', over=TRUE))
(BS.terra.sa2<-projectRaster(from=BS.terra,  res=5000,
crs=prj.StudyAreaPositive, method='ngb', over=F))
(BS.terra.sa3<-projectRaster(from=BS.terra,  res=5000, crs=prj.StudyArea,
method='ngb', over=TRUE))
(BS.terra.sa4<-projectRaster(from=BS.terra,  res=5000, crs=prj.StudyArea,
method='ngb', over=F))
## plot
par(mfrow=c(5,1))
plotRGB(BS.terra)
plotRGB(BS.terra.sa1)
plotRGB(BS.terra.sa2)
plotRGB(BS.terra.sa3)
plotRGB(BS.terra.sa4)
#

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list