Load libraries

library(duckdbfs)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union
library(jsonlite)
library(sf)
Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE

Load data

holc <- open_dataset(
    "https://data.source.coop/cboettig/mappinginequality/mappinginequality.parquet"
)
datacenters <-
    "https://s3-west.nrp-nautilus.io/public-datacenters/data_centers.geojson"
holc <- holc |>
    mutate(area_ha = sql("ROUND(ST_Area_Spheroid(ST_FlipCoordinates(geom)) / 10000.0, 2)"))

holc |>
    select(-geom_bbox) |>
    write_geo("holc.geojson")
[1] 10154
library(mapgl)


m <- maplibre(
    center = c(-118.35, 34.05),
    zoom = 8
) |>
    add_source(
        id = "holc",
        data = "https://espm-288.github.io/spatial-cboettig/holc.geojson"
    ) |>
    add_fill_layer(
        id = "redlining",
        source = "holc",
        fill_color = match_expr(
            column = "grade",
            values = c("A", "B", "C", "D"),
            stops = c("#76a865", "#7cb5bd", "#ffff00", "#d9838d")
        ),
        fill_opacity = 0.65,
        tooltip = "area_ha"
    )

m