mapgl icon indicating copy to clipboard operation
mapgl copied to clipboard

Altering arguments in add_heatmap_layer() for extremely high densities of points

Open ConnorFlynn opened this issue 1 year ago • 0 comments

Hi Kyle, I am really enjoying your 3 part workshop on mapgl! I am trying to utilize the package for Machine Learning predicted points of marine plastic off of windward Oahu. There is 171,000 points of predicted plastic in the bounding box. Is there something within the arguments of add_heatmap_layer() that can fix this?

My code:

knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(here)
library(mapgl)
library(sf)
library(tidycensus)

Read in Data

plastics <- read_csv(here("Plastic.csv"))

Turn Lat & Longs to point geometries

plastics_sf <- plastics %<>% 
  st_as_sf(coords = c("longitude", "latitude")) %>% 
  st_sf(crs = 4326)

Pull in Hawaii Data

hawaii <- get_acs(
  state = "HI",
  county = "Honolulu",
  geography = "tract",
  variables = "B19013_001",
  geometry = TRUE,
  year = 2020
)

Base map

hi_map <- mapboxgl(
  style = mapbox_style("light"),
  bounds = hawaii
)

output:

https://github.com/user-attachments/assets/ad0d327c-ee6f-44fa-9c76-f906efec26b2

Here is an output I got with hex bins using tmap

Screen Shot 2024-07-26 at 2 03 36 PM

Thanks!

ConnorFlynn avatar Aug 07 '24 22:08 ConnorFlynn