I have a RasterBrick for a landsat image:
landsat_stack_brick
#class : RasterBrick
#dimensions : 7711, 7551, 58225761, 7 (nrow, ncol, ncell, nlayers)
#resolution : 30, 30 (x, y)
#extent : 576885, 803415, 2281485, 2512815 (xmin, xmax, ymin, ymax)
#crs : +proj=utm +zone=4 +datum=WGS84 +units=m +no_defs
#source : r_tmp_2022-11-19_144142_2384_62790.grd
#names : B1, B2, B3, B4, B5, B6, B7
#min values : 1, 1, 1, 4, 1780, 6138, 7110
#max values : 60301, 61806, 61527, 62936, 62293, 65454, 65454
I want to add points in longitude/latitude to the plot of landsat_stack_brick
library(raster)
Long_lat_df = na.omit(water_long_lat)
coordinates(Long_lat_df ) <- ~ water_long + water_lat
proj4string(Long_lat_df ) <- CRS("+init=epsg:4326")
y <- spTransform(geo_points, crs(landsat_stack_brick))
plot(landsat_stack_brick)
points(y)
The points should be all along the coast lines of the islands, but this is how it looks when I try to add them to the map:
The code used thus far is: [EDIT: Applying corrections mentioned by John Polo]
water_chem <- read.csv("data.csv")
###Extract all first unique values obtained for latitude)
water_lat = unique(water_chem$Latitude)
###Extract all corresponding longitutude values for unique latitud ###values found
water_long= water_chem$Longitude[unique(water_chem$Latitude)]
x <- water_long_lat
x = na.omit(x)
coordinates(x) <- ~ water_long + water_lat
sbux_sf <- st_as_sf(x, coords = c("water_long", "water_lat"), crs = landsat_stack@crs)
sbux_sd
structure(list(geometry = structure(list(structure(c(-156.63776,
21.0133265), class = c("XY", "POINT", "sfg")), structure(c(-156.63776,
21.0134451), class = c("XY", "POINT", "sfg")), structure(c(-156.63776,
21.0135265), class = c("XY", "POINT", "sfg")), structure(c(-156.63776, [...]
[...], precision = 0, bbox = structure(c(xmin = -156.6407, ymin = 20.77606,
xmax = -156.63776, ymax = 21.014317), class = "bbox"), crs = structure(list(
input = "WGS 84", wkt = "GEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]],\n ID[\"EPSG\",6326]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8901]],\n CS[ellipsoidal,2],\n AXIS[\"longitude\",east,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]],\n AXIS[\"latitude\",north,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433,\n ID[\"EPSG\",9122]]],\n USAGE[\n SCOPE[\"unknown\"],\n AREA[\"World.\"],\n BBOX[-90,-180,90,180]]]"), class = "crs"), n_empty = 0L)), row.names = c(NA,
124L), class = c("sf", "data.frame"), sf_column = "geometry", agr = structure(integer(0), class = "factor", .Label = c("constant",
"aggregate", "identity"), .Names = character(0)))