Monday 31 July 2017

R : How to build heatmap with the leaflet package


I read a post about interactive maps with R using the leaflet package.


In this article, the author createD a heat map like this:



X=cbind(lng,lat)
kde2d <- bkde2D(X, bandwidth=c(bw.ucv(X[,1]),bw.ucv(X[,2])))

x=kde2d$x1
y=kde2d$x2
z=kde2d$fhat
CL=contourLines(x , y , z)

m = leaflet() %>% addTiles()
m %>% addPolygons(CL[[5]]$x,CL[[5]]$y,fillColor = "red", stroke = FALSE)


I am not familiar with the bkde2D function, so I'm wondering if this code could be generalized to any shapefiles?


What if each node has a specific weight, that we would like to represent on the heat map?


Are there other ways to create a heat map with leaflet map in R ?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...