Last active
June 6, 2020 04:09
-
-
Save coolbutuseless/2bdaa9a28c5da30ba86f09b701022899 to your computer and use it in GitHub Desktop.
ceramic test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Define the extents of the image | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
roi <- raster::extent(110, 160, -45, -12) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Grab the satellite image and the elevation map | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
im <- ceramic::cc_location(roi) | |
el <- ceramic::cc_elevation(roi) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Extract the raw image data | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
imdata <- im@data@values | |
imdata <- array(as.vector(imdata), dim = c(im@ncols, im@nrows, 3)) | |
imdata <- aperm(imdata, c(2, 1, 3)) | |
imdata <- imdata/255 | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# Extract the raw elevation data into | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
el2 <- el | |
# el2 <- raster::resample(el2, im) # results in some NA values | |
# el2 <- raster::aggregate(el2, 2) # doesn't result in an exact size match with 'im' | |
# res(el2) <- res(im) # results in all NA values. Still not an exact size match | |
# dim(el2) <- dim(im)[1:2] # results in all NAs | |
eldata <- matrix(el2@data@values, nrow = el2@ncols, ncol = el2@nrows) | |
eldata <- t(eldata) | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
# These two data objects are different sizes! | |
# The elevation data, is almost but now quite 2x the | |
# resolution of the image data. What's the best way to align their dimensions? | |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
dim(imdata) | |
dim(eldata) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment