Skip to content

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

@ConnorFlynn

Description

@ConnorFlynn

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:

Screen.Recording.2024-08-07.at.12.42.32.PM.mp4

Here is an output I got with hex bins using tmap

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

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions