Skip to content

Importing xlsm & blinking circilemarkers

3 messages · Roger Bivand, sownal chand

#
Hello sir/madam,

I have a macro-enabled excel file and wanted to import the data that this
file automatically grabs everytime the macro is run. Are there any packages
for macro-enabled excel?

I have written some codes using a leaflet package and was trying to set
criteria for circle markers that if the Rainfall value is in the ranges the
color of the markers would change and start blinking. Given for green
0-20mm, yellow - 20-30mm, orange- 30-50mm, red- >= 50mm.

Given below is the code and sample data
library(sf)
library(leaflet)

#Make Leaflet map with markers
leaflet() %>%
  addTiles() %>%
  addCircleMarkers(lat = rainfall$Latitude,
                   lng = rainfall$Longitude)

# Add Data for rainfall
col_pal <- colorNumeric(palette = "viridis",
                        domain = rainfall$rainfall)

#adding content to the popups
#Make map with colors with markers
Map<- leaflet() %>%
  addTiles() %>%
  addCircles(lat = Rainfall$Latitude,
           lng = Rainfall$Longitude,
           color = col_pal(Rainfall_plots$Rainfall),
           radius = 2000,
          fillOpacity = 0.8,
          label =  Rainfall_plots$rainfall) %>%
 addLegend(position = "bottomleft", pal = col_pal, values =
Rainfall_plots$rainfall, title = "Rainfall Indicator")

Map
********************************************************************************************************

The code is correct, some ideas to set up criterias for the rainfall amount
would really be appreciated. And possibly the codes as well would be really
wonderful. Also attached is the sample data in csv format

Thanking you in advance
Sownalc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20220317/42348da3/attachment.html>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: RainfalSample.csv
Type: application/vnd.ms-excel
Size: 859 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20220317/42348da3/attachment.xlb>
1 day later
#
On Thu, 17 Mar 2022, sownal chand wrote:

            
No idea, sounds like something for shiny, which I avoid. Interactive 
graphics are very hard to do right at the best of times.
library(sf)
rainfall <- st_as_sf(read.csv("RainfalSample.csv"), coords=c("Long",
  "Lat"), crs="OGC:CRS84")
library(tmap)
tmap_mode("view")
tm_shape(rainfall) + tm_symbols(size=0.0025, col="Rainfall.mm.",
  style="fixed", breaks=c(0, 20, 30, 50, Inf), pal=c("green", "yellow",
  "orange", "red"))

may be fairly close. tmap is a package using leaflet internally, mapview 
is another such package. Many of the symbols overlap, so are not very 
legible.

Hope this helps,

Roger

  
    
#
Hi Roger

Thanks for your help and support.

Have a blessed weekend
Sownalc
On Sat, Mar 19, 2022, 01:47 Roger Bivand <Roger.Bivand at nhh.no> wrote: