Creating Map from coordinates in data frame


I am creating a shiny app where the data is being retrieved from an xlsx sheet.

In the excel worksheet, I have the name of the countries to map. Each country is divided into 50*50 grids.

Each grid has 2 coordinates (lat and long) which point to the centroid of the cubic grid.

I would like to create a shiny app where I can filter by country, month, and year and obtain the cubic grids for each country mapped over the base map.

I haven't succeeded in that yet.

I have tried using leaflet, ggplot2, and highcharter but I haven't been successful at finding a solution yet

Any help is highly appreciated


What have you done so far?

Would it be better to join to the polygons of the country rather than the centroid?

if so? how would i be able to visualize the grids as cubes of certain dimensions?

so far i haven't been able to visualize anything, i only added the buttons for filtering etc...

I am hoping to be able to do something like this

What works? What doesn't? Share some code.

    menuItem(" Data",tabName=" Data",icon =icon("dashboard"))
              box(title="Please choose a country,month and year (Selecting Multiple countries is possible)", width=12,status="warning",solidHeader=TRUE,
                  selectInput("Country","Country",choices=countries_list, multiple=FALSE),
                  downloadButton("DownloadData","Download Data as csv"))
              ##box(title = "Grids",width=12,leafletOutput("Leafplot", height = 250),status = "primary",solidHeader = TRUE)



#Interactive filters & download button tab 
      data_filtered<-df_Main%>%filter(country %in% input$County)%>%filter(month_name %in% input$Month)%>%filter(year %in% input$Year)
  output$Map <- renderHighchart({

    data_filtered<-df_Main%>%filter(country %in% input$County)%>%filter(month_name %in% input$Month)%>%filter(year %in% input$Year)

df_Main is the data frame that reads from excel where I have the coordinates for the grids
So far I have been able to visualize the select input buttons with a static image of the worldmap

It is not reproducible because we don't have your data.

What is wrong with it? What error messages do you get?

I do not get any error, I just get the world map blank empty and it does not change if I choose a certain country

Change this to Country (missing 'r').

what I am aiming to do but still don't know how to do it, is to have at any time i choose a certain country, to have the country map only with the cubic grids as an overlay maybe....

Ow! okay now what i am getting is the country selected in blue

This should be a reactive value. See:

Edit: Actually maybe not. It isn't in the example here, but it normally would be. highcharter-shiny/app.R at master · jbkunst/highcharter-shiny · GitHub

I will give it a try

Big thanks, will keep u posted

1 Like