0

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

Majid
  • 1,836
  • 9
  • 19
  • There are many ways to do this using `ggmap`, `leaflet` and more! Please make a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) and be more specific. – Majid Oct 12 '19 at 23:54
  • Thank you! I was trying "oceanmap" , it is not working. I will try the suggested package. – Dieunel Derilus Oct 13 '19 at 00:11

1 Answers1

0

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

dswdsyd
  • 576
  • 4
  • 12