Search code examples
rplotheatmapgeography

generate Global oceanic heatmap with abundance data


I have species abundance for different geographical locations in the global ocean. I want to generate a heatmap showing the abundance of my species with a color gradient. Here is the header of the data

Is there any package in R or R code that could help me to visualize this as a heatmap(geography)?

Thanks in advance


Solution

  • leaflet is really powerful and really recommend the library.

    Here is an example:

    > library(leaflet)
    > fishes <- data.frame(lat=c(-47.2,-20.4,-20.9),long=c(-57.9,-3.2,-35.2),abudance=c(5,1,17),samples=c("s1","s2","s3"))
    > fishes
        lat  long abudance samples
    1 -47.2 -57.9        5      s1
    2 -20.4  -3.2        1      s2
    3 -20.9 -35.2       17      s3
    
    > leaflet(fishes) %>% addTiles() %>%
    +     addCircles(lng = ~long, lat = ~lat, weight = 1,
    +                radius = ~abudance *20000, popup = ~samples
    +     ) %>% addTiles() %>% addMarkers(~long, ~lat, popup = ~as.character(abudance), label = ~as.character(abudance))
    
    

    The above code will generate this: Pic

    To customise the popups and points, refer to these pages:

    https://rstudio.github.io/leaflet/markers.html

    https://rstudio.github.io/leaflet/popups.html

    https://rstudio.github.io/leaflet/colors.html