R/coordinate_conversion.R
mt_bbox.Rd
Converts lower-left sinusoidal coordinates to lat-lon sf bounding box
mt_bbox(xllcorner, yllcorner, cellsize, nrows, ncols, transform = TRUE)
lower left x coordinate as provided by
mt_subset
lower left y coordinate as provided by
mt_subset
cell size provided by mt_subset
cell size provided by mt_subset
cell size provided by mt_subset
transform the bounding box from sin to lat long coordinates,
TRUE
or FALSE
(default = TRUE
)
# \donttest{
# Download some test data
subset <- mt_subset(product = "MOD11A2",
lat = 40,
lon = -110,
band = "LST_Day_1km",
start = "2004-01-01",
end = "2004-03-31",
progress = FALSE)
# convert sinusoidal to lat / lon
lat_lon <- sin_to_ll(subset$xllcorner, subset$yllcorner)
# bind with the original dataframe
subset <- cbind(subset, lat_lon)
# convert to bounding box
bb <- apply(subset, 1, function(x){
mt_bbox(xllcorner = x['xllcorner'],
yllcorner = x['yllcorner'],
cellsize = x['cellsize'],
nrows = x['nrows'],
ncols = x['ncols'])
})
head(bb)
#> $`1.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
#> $`2.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
#> $`3.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
#> $`4.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
#> $`5.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
#> $`6.1`
#> Geometry set for 1 feature
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -110.0023 ymin: 39.99167 xmax: -109.978 ymax: 40
#> Geodetic CRS: WGS 84
#> POLYGON ((-109.9889 39.99167, -110.0023 40, -10...
#>
# }