Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I need to create a map that shows the connection between two points (both airports).
Origin / Destination airport must be from different tables.
R libraries: maps / geosphere / magritt
The main problem that I have is that the script in PowerBI doesn't draw both points, but in R-Studio works fine.
Images:
https://ibb.co/cN8VWz
https://ibb.co/e9Phde
https://ibb.co/jSJm4K
R code of R visual:
library(maps) library(geosphere) library(magrittr) map("world", xlim=c(-10,5),ylim=c(35,44) ,col="#1a2732", bg="white", fill=TRUE, lty = 0, interior = false,mar = c(0.1, 0.1, 0, 0.1)) OrigenDataset <-dataset [c(1,2,3,4)] DestinoDataset <-dataset [c(5,6,7,8)] O.Lat <- OrigenDataset$O.Latitude O.Lon <- OrigenDataset$O.Longitude D.Lat <- DestinoDataset$D.Latitude D.Lon <- DestinoDataset$D.Longitude OrigenPunto <- c(O.Lon,O.Lat) DestinoPunto <- c(D.Lon,D.Lat) p1 <- c(O.Lon,D.Lon) p2 <- c(O.Lat,D.Lat) points(x=p1, y=p2, col="#96ce00", cex=2, pch=20) # Connection between Barcelona, Madrid #inter <- gcIntermediate(OrigenPunto, DestinoPunto, n=50, addStartEnd=TRUE, breakAtDateLine=F) #lines(inter, col="#96ce00", lwd=2)
Pbix file: https://drive.google.com/open?id=1pZNdJRleudTBXXG9LT4II26GOJWxS0Jc
Airports file: https://drive.google.com/open?id=1KuktzNZ_2eatqLFwfHV9C_7MOwTqN0RG
The final purpose is to draw a line between the two airports.
Please... help.
Thanks 🙂
Luis
Solved! Go to Solution.
I have found the solution:
library(maps) library(geosphere) library(magrittr) Punto1 <- c(dataset$O.Lon,dataset$O.Lat) Punto2 <- c(dataset$D.Lon,dataset$D.Lat) map("world", xlim=c(-10,5),ylim=c(35,44) ,col="#1a2732", bg="white", fill=TRUE, lty = 0, interior = false,mar = c(0.1, 0.1, 0, 0.1)) points(x=dataset$O.Lon, y=dataset$O.Lat, col="#96ce00", cex=2, pch=20) points(x=dataset$D.Lon, y=dataset$D.Lat, col="#96ce00", cex=2, pch=20) inter <- gcIntermediate(Punto1, Punto2, n=50, addStartEnd=TRUE, breakAtDateLine=F) lines(inter, col="#96ce00", lwd=2)
The easiest one 🙂
I have found the solution:
library(maps) library(geosphere) library(magrittr) Punto1 <- c(dataset$O.Lon,dataset$O.Lat) Punto2 <- c(dataset$D.Lon,dataset$D.Lat) map("world", xlim=c(-10,5),ylim=c(35,44) ,col="#1a2732", bg="white", fill=TRUE, lty = 0, interior = false,mar = c(0.1, 0.1, 0, 0.1)) points(x=dataset$O.Lon, y=dataset$O.Lat, col="#96ce00", cex=2, pch=20) points(x=dataset$D.Lon, y=dataset$D.Lat, col="#96ce00", cex=2, pch=20) inter <- gcIntermediate(Punto1, Punto2, n=50, addStartEnd=TRUE, breakAtDateLine=F) lines(inter, col="#96ce00", lwd=2)
The easiest one 🙂
Hi @Anonymous
You may have a look at below post for reference.
https://community.powerbi.com/t5/R-Script-Showcase/Map-with-connecting-lines/td-p/80294
Regards,
Cherie
It's not the same case. Australia's data is on the same dataframe-table, but my map needs as source two different tables... 😕
Thank you anyway 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
96 | |
93 | |
83 | |
70 | |
65 |
User | Count |
---|---|
118 | |
106 | |
93 | |
79 | |
72 |