library(sf)
# Toy polygon in a projected CRS
poly <- st_sfc(st_polygon(list(rbind(
c(0,0), c(1,0), c(1,1), c(0,1), c(0,0)
))), crs = 3857)
# Default center (bbox midpoint), gentle magnification
out1 <- sf_fisheye(poly, r_in = 0.3, r_out = 0.6,
zoom_factor = 1.5, squeeze_factor = 0.35)
# Explicit map-unit center, stronger focus
out2 <- sf_fisheye(poly, cx = 0.5, cy = 0.5,
r_in = 0.25, r_out = 0.55,
zoom_factor = 2.0, squeeze_factor = 0.25)
# Lon/lat point (auto-project to UTM/MGA), then fisheye around CBD (WGS84)
pt_ll <- st_sfc(st_point(c(144.9631, -37.8136)), crs = 4326) # Melbourne CBD
out3 <- sf_fisheye(pt_ll, r_in = 0.2, r_out = 0.5)
# Center supplied as an sf polygon: centroid is used as the warp center
out4 <- sf_fisheye(poly, center = poly)
Run the code above in your browser using DataLab