0

it is a rather untypical scenario, I am using R Custom visual in PowerBI to plot a raster and the only way to pass data is by using a dataframe.

this what I have done so far, generate a raster in R save it to file using SaveRDS encoded the file as a base64 and save it as a csv.

now using this code I manage to read the csv, load it to a dataframe combine al the rows

my question is how to decode it back to a raster Object ?

here is a reproducible example

# Input load. Please do not change #
`dataset` = read.csv('https://raw.githubusercontent.com/djouallah/keplergl/master/raster.csv', check.names = FALSE, encoding = "UTF-8", blank.lines.skip = FALSE);
# Original Script. Please update your script content here and once completed copy below section back to the original editing window #
library(caTools)
library(readr)
dataset$Value <- as.character(dataset$Value)
dataset <- dataset[order(dataset$Index),]
z <- paste(dataset$Value)
Raster <- base64decode(z,"raw")

here is the result enter image description here

Mim
  • 999
  • 10
  • 32

1 Answers1

0

it turned out the solution is very easy, saveRDS has an option to save with ascii = TRUE

saveRDS(background,'test.rds',ascii = TRUE,compress = FALSE)

now I just read it as humain readbale format (which is easy to load to PowerBI) and it works

fil <- 'https://raw.githubusercontent.com/djouallah/keplergl/master/test.rds'

cony <- gzcon(url(fil))

XXX <- readRDS(cony,refhook = NULL)
plotRGB(XXX)
Mim
  • 999
  • 10
  • 32