I have an extent object that I would like to re-project to lat and lon.
>outer_extent
outer_extent
class : Extent
xmin : -5559753
xmax : -4447753
ymin : -4447852
ymax : -3335852
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityI have an extent object that I would like to re-project to lat and lon.
>outer_extent
outer_extent
class : Extent
xmin : -5559753
xmax : -4447753
ymin : -4447852
ymax : -3335852
You could just coerce the extent into a SpatialPolygons object and then use "spTransfrom".
library(sp)
( e <- raster::extent(-5559753, -4447753, -4447852, -3335852) )
e <- as(e, "SpatialPolygons")
sp::proj4string(e) <- "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181
+b=6371007.181 +units=m +no_defs"
e.geo <- sp::spTransform(e, CRS("+proj=longlat +datum=WGS84 +no_defs
+ellps=WGS84 +towgs84=0,0,0"))
Plot resulting extents
par(mfrow=c(1,2))
plot(e)
title("Original extent")
plot(e.geo)
title("Geographic extent")
Looks like this can be done using the raster package. There is a projectExtent function that returns a warped raster object. Then just need to extract extent().
extent(projectExtent(raster_object,"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
Thanks to mdsumner's comment!