This is a follow up to my previous question. I wrote code that imports the boundaries of a few US states, and, for some arbitrary point within those boundaries, buffers a circle around that point and then draws both on a map.\
Even though the latitude and longitude specified fall squarely within the boundaries, they don't appear this way on the map. Am I using the wrong projection? I chose the Albers projection per this question. I guessed that this may be the problem because the axes aren't in longitude and latitude either; they seem arbitrary.
This is the output, which is incorrect. The blue point/buffer should be in the northwest quadrant of the red map.
This is the code:
library(sf) library(tidyverse) library(USAboundaries) albers_proj <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m +no_defs" # download county boundaries counties <- us_counties(map_date = "2000-01-01", resolution = "high", states = c("Utah", "New Mexico", "Colorado", "Arizona")) counties <- counties %>% st_transform(albers_proj) # example point lon <- -111.101099 lat <- 40.477140 elev <- 150 tower <- st_point(x = c(lon, lat, elev), dim = "XYZ") tower <- tower %>% st_sfc(crs = albers_proj) # draw the radio horizon around the tower scalar <- 3.57 radius <- scalar * sqrt(tower[]) * 1000 tower_buffer <- st_buffer(tower, dist = radius) xlim <- c(-2e06, 1e06) ylim <- c(-6e05, 6e05) png("map.png", width = 1100, height = 850, units = "px") plot(st_geometry(counties), col = adjustcolor("maroon", alpha=0.5), xlim=xlim, ylim=ylim, axes=TRUE) plot(st_geometry(tower_buffer), col = adjustcolor("blue", alpha=0.5), add=TRUE) dev.off()