Open DanielBGAtlas opened 1 year ago
I updated the packages directly from Github and everything is working fine now.
Hey, could you help me with rayshader, I have my gpkg file already done. I use the following script but all time i have this error : Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric-alike variables
Need serious help please 👍
library(tigris)
library(tidyverse)
library(stars)
library(rayshader)
library(MetBrewer)
library(colorspace)
library(units)
library(elevatr)
data <- st_read("reunion.gpkg")
st_data <- st_intersection(data)
bb <- st_bbox(data)
bottom_left <- st_point(c(bb[["xmin"]], bb[["ymin"]])) |>
st_sfc(crs = st_crs(data))
bottom_right <- st_point(c(bb[["xmax"]], bb[["ymin"]])) |>
st_sfc(crs = st_crs(data))
data |>
ggplot() +
geom_sf() +
geom_sf(data = bottom_left) +
geom_sf(data = bottom_right, color = "red")
width <- st_distance(bottom_left, bottom_right)
top_left <- st_point(c(bb[["xmin"]], bb[["ymax"]])) |>
st_sfc(crs = st_crs(data))
height <- st_distance(bottom_left, top_left)
if (width > height) {
w_ratio <- 1
h_ratio <- height / width
} else {
h_ration <- 1
w_ratio <- width / height
}
size <- 5000
rast <- st_rasterize(st_data,
nx = floor(size * w_ratio),
ny = floor(size * h_ratio))
mat <- matrix(data$population,
nrow = floor(size * w_ratio),
ncol = floor(size * h_ratio))
mat|>
height_shade()|>
plot_3d(heightmap = population)
Thx for help
Hi!
I'm following one of your projects with the Kontur population data, in my case for Spain. I started following your steps, downloading the data, intersecting with the region I want to plot and ploting in 3D with with:
My problem is that after doing that, what is rendered is "blank" square with no relation with the geography I want to plot. I tried with several geographies and even using data not coming from the Kontur dataset and the result is always the same:
My code so far:
I don't know if I'm doing something wrong with the crs, but I tried changing the data I'm using and the result is always the same.
Any tips would be greatly appreciated.