Forum Discussion

ctruxillo's avatar
ctruxillo
Regular Visitor
3 years ago

Mapping with R code Leaflet or other packages

Hi I am trying to build a map that I can connect cordinates and fill in the area. I have had success with Rstudio but would prefer to get the code to work in PowerBi.  the Rstudio code I used is 

 

library(dplyr)
library(leaflet)

map<-leaflet(width =500, height= 500) %>%
addTiles() %>%
addPolygons(lng =                c(-76.12483,-75.49118,-75.01104,-75.05677,-75.37360,-76.27835,-77.11451,-76.60171,-76.77809,-76.50045,-76.12483), lat=c(38.56060,39.18615,38.64739,37.87028,37.49547,37.17344,37.33463,38.01968,38.34830,38.59635,38.56060)) %>%
addCircles(lng = c(-76), lat= c(38), color ="red",weight = 70 )

 

map

 

 

 

I am hand writting the cordinates to test but plan on using a datafile instead. The issue I am getting is that Power Bi is reporting  that no visual was created, but this produces one in Rstudio. From my understanding, leaflet is supported in PowerBi (according to Learn which R packages are supported - Power BI | Microsoft Learn). 

 

 

Is there something else I would need to add to the code to get it to show up? Are there better packages for the job? Heck, if there is a good power bi specific solution I would love that. Thanks for your input!

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ctruxillo ,

     

    Please make sure you have installed the node.js.

    Here is a solved post with similar issue like yours, I hope it could help you.

    You may refer to offical blogs to learn more details.

    For reference:

    Run R scripts in Power BI Desktop

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.