The scidbutil package provides a set of utlitary functions for working with multidimensional arrays of Earth observation data hosted in SciDB. This vignette is meant to introduce users to some usage examples.

Coordinate transformation: WGS84 to MODIS sinusoidal

MODIS uses a synusoidal projection to spatially represent their data. The SR-ORG code of this projection is 6974.

A common task while working with MODIS data is to transform coordinates from and to MODIS sinusoidal projection. Below, we present the case of WGS84.

library(scidbutil)
library(sp)

# create the coordinate systems
proj4326 <- "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"
proj_modis_sinusoidal <- "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"

# create a matrix of points
x <- c(-56.239700, -56.325531)
y <- c(-11.623990, -11.676781)
lonlat.mat <- cbind(x, y)

# build spatial-points
S <- SpatialPoints(lonlat.mat)
proj4string(S) <-CRS(proj4326)

# transform to MODIS sinusoidal
modis.sp <- spTransform(S, CRS(proj_modis_sinusoidal))

# transform back to WGS84
(wgs84.sp <- spTransform(modis.sp, CRS(proj4326)))

Coordinate transformation: WGS84 to SciDB column and row

Now, we need to obtain the position of a pixel in the array and we have the pixel's WGS84 coordinates. In other words, we need to transform from longitude and latitude to col_id and row_id.

library(scidbutil)

# calculate the size of a MODIS pixel
pixelSize <- calcPixelSize(4800, calcTileWidth())

# do the coordinate transformation
(res <- wgs84gmpi(lonlat.mat, pixelSize))

Transform time ids into dates

The scidbutil package also provides functions to transform from and to time reference systems.

tid <- 0:2
MOD13Q1.period <- 16 
(date.vector <- time_id2date(time_id.vector = tid, period = MOD13Q1.period))


albhasan/scidbutil documentation built on May 24, 2019, 2:48 p.m.