Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

R visual · leaflet (air route)

Hi!

 

I have tried to do a R visual with "maps", "geosphere" and "leaflet" packages, to draw a line route beetween two points, but PowerBI doesn't show anything, I only get this message: "No image was created. The R code didn't result in creation of any visual. Make sure your R script results in a plot to the R default device".

 

The data is quite simple (is just an example):

 

 

 

 

Code from PowerBi's R scipt editor:

 

#Create dataframe

dataset <- data.frame(RUTA, ORIGEN, LAT1, LON1, DESTINO, LAT2, LON2)

 

#libraries

library(maps)
library(geosphere)
library(leaflet)

 

# geo-code

gcIntermediate(c(dataset[1,]$LON1, dataset[1,]$LAT1), c(dataset[1,]$LON2, dataset[1,]$LAT2),n=100,
addStartEnd=TRUE,
sp=TRUE) %>%
leaflet() %>%
addTiles() %>%
addPolylines()

 

In the other hand, if I run the script in R-Studio I get the map:

 

 

R code:

 

# Input load. Please do not change #
`dataset` = read.csv('xxx.csv', check.names = FALSE, encoding = "UTF-8", blank.lines.skip = FALSE);

library(maps)
library(geosphere)
library(leaflet)

gcIntermediate(c(dataset[1,]$LON1, dataset[1,]$LAT1), c(dataset[1,]$LON2, dataset[1,]$LAT2),n=100, 
               addStartEnd=TRUE,
               sp=TRUE) %>% 
  leaflet() %>% 
  addTiles() %>% 
  addPolylines()

Thank you very much,

Luis

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may have a look at below articles to check if those are helpful or not.

 

https://community.powerbi.com/t5/Desktop/R-graphics-libraries-does-not-work-in-PBI/td-p/259473

https://medium.com/@dr_eldersveld/r-visuals-in-power-bi-beyond-plots-74c618f2e6f3

https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-cherch-msft
Employee
Employee

Hi @Anonymous

 

You may have a look at below articles to check if those are helpful or not.

 

https://community.powerbi.com/t5/Desktop/R-graphics-libraries-does-not-work-in-PBI/td-p/259473

https://medium.com/@dr_eldersveld/r-visuals-in-power-bi-beyond-plots-74c618f2e6f3

https://docs.microsoft.com/en-us/power-bi/desktop-r-visuals

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.