ייבוא קורדינציות X ו Y והצגתם על גבי מפת גוגל

16 views
Skip to first unread message

Lior Smadja

unread,
Mar 4, 2018, 1:58:45 PM3/4/18
to Israel R User Group
שלום רב לכולם ,

במסגרת פרויקט שלי, אני צריך לקרוא קובץ CSV שמכיל שלושה עמודות : X ו Y ו ID .

אני נדרש להציג את הנקודות על גבי מפת גוגל , ולתת לכל נקודה אייקון אחר לפי מזהה הID .

רציתי לדעת מה הדרך הכי נוחה לעשות את זה בSHINY? אני נדרש לקרוא בכל X זמן את קובץ הCSV ולהציג נקודות חדשות או נקודות שהשתנו על המפה .

האם מישהו ביצע בעבר משהו דומה?


תודה מראש.

Michael Dorman

unread,
Mar 5, 2018, 12:12:22 AM3/5/18
to israel-r-...@googlegroups.com
שלום ליאור,

דרך נוחה לעשות את מה שתיארת היא ליצור מפה עם רקע של גוגל בעזרת ספריית ggmap, שם תוכל להוסיף נקודות על גבי המפה עם geom_point -

לאחר מכן תוכל להציג את המפה באפליקציית shiny עם plotOutput בדומה לכל פלט גרפי אחר - 

יום טוב,

מיכאל

--
You received this message because you are subscribed to the Google Groups "Israel R User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to israel-r-user-group+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

eliav schmulewitz

unread,
Mar 5, 2018, 1:44:13 AM3/5/18
to Israel R User Group
הנה קישור למשהו שעשיתי בעבר 
דבר איתי אם אתה צריך

Omri Mendels

unread,
Mar 5, 2018, 3:42:15 AM3/5/18
to Israel R User Group
Having checked multiple maps packages, I think that the best shiny option is leaflet. It's interactive (you can play with the map) and the syntax is really simple, and looks a lot like dplyr.

Here's a very simple example which shows markers on a map and text (id) above them
library(leaflet)
dataset
= data.frame(lon = rnorm(20,34.9,0.01),lat = rnorm(20,32.15,0.01),id = 1:20)


map
<- leaflet(data = dataset) %>%
  addTiles
() %>%
  addMarkers
(label = ~as.character(id),
             labelOptions
= labelOptions(noHide = T, direction = 'top', textOnly = T))
print(map)



This is a full shiny app that displays points on a map. You could extend it to use your own data, add tooltips and legends to show IDs and additional metadata per point.

library(shiny)
library
(leaflet)

r_colors
<- rgb(t(col2rgb(colors()) / 255))
names
(r_colors) <- colors()

ui
<- fluidPage(
 leafletOutput
("mymap"),
 p
(),
 actionButton
("recalc", "New points")
)

server
<- function(input, output, session) {

 points
<- eventReactive(input$recalc, {
 cbind
(rnorm(40) * 2 + 13, rnorm(40) + 48)
 
}, ignoreNULL = FALSE)

 output$mymap
<- renderLeaflet({
 leaflet
() %>%
 addProviderTiles
(providers$Stamen.TonerLite,
 options
= providerTileOptions(noWrap = TRUE)
 
) %>%
 addMarkers
(data = points())
 
})
}

shinyApp
(ui, server)


source for 2nd example:
https://rstudio.github.io/leaflet/shiny.html

More about leaflet:
https://rstudio.github.io/leaflet/


On Sunday, March 4, 2018 at 8:58:45 PM UTC+2, Lior Smadja wrote:

Lior Smadja

unread,
Mar 5, 2018, 11:41:49 AM3/5/18
to Israel R User Group
תודה לכולם ,

האם מישהו מכיר דרך לבצע את הדרישה הבאה:

קריאה בכל X זמן את קובץ הCSV ולהציג נקודות חדשות או נקודות שהשתנו על המפה ?



בתאריך יום ראשון, 4 במרץ 2018 בשעה 20:58:45 UTC+2, מאת Lior Smadja:

Omri Mendels

unread,
Mar 6, 2018, 1:36:29 AM3/6/18
to israel-r-...@googlegroups.com
you could use anti_join between the old dataset and the new dataset, and present the outcome, which would only have records that appear on the new dataset and not the old.

See here:
http://zevross.com/blog/2014/08/05/using-the-r-function-anti_join-to-find-unmatched-records/

--
You received this message because you are subscribed to a topic in the Google Groups "Israel R User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/israel-r-user-group/VBCsxElQbfs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to israel-r-user-group+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages