Skip to content

Commit 36fc15b

Browse files
committed
fix sf object creation in the s2-tile handling
1 parent 0410cb8 commit 36fc15b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

R/api_s2tile.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
} else {
1919
# create a sf of points
2020
epsg_lst <- unique(s2_tb[["epsg"]])
21-
points_sf <- sf::st_cast(.map_dfr(epsg_lst, function(epsg) {
21+
points_sf <- sf::st_as_sf(.map_dfr(epsg_lst, function(epsg) {
2222
tiles <- dplyr::filter(s2_tb, epsg == {{epsg}})
2323
sfc <- matrix(c(tiles[["xmin"]], tiles[["ymin"]]), ncol = 2) |>
2424
sf::st_multipoint(dim = "XY") |>
2525
sf::st_sfc(crs = epsg) |>
2626
sf::st_transform(crs = "EPSG:4326")
2727
sf::st_sf(geom = sfc)
28-
}), "POINT")
29-
28+
}))
29+
points_sf <- sf::st_cast(points_sf, "POINT")
3030
# change roi to 1.5 degree to west and south
3131
roi_search <- .bbox_as_sf(
3232
dplyr::mutate(
@@ -58,7 +58,7 @@
5858
})
5959

6060
# transform each sf to WGS84 and merge them into a single one sf object
61-
s2_tiles <- .map_dfr(s2_sf_lst, function(s2_sf) {
61+
s2_tiles <- sf::st_as_sf(.map_dfr(s2_sf_lst, function(s2_sf) {
6262
s2_sf <- sf::st_as_sf(
6363
x = s2_sf,
6464
sf_column_name = "geom",
@@ -68,7 +68,7 @@
6868
x = sf::st_segmentize(s2_sf, 10980),
6969
crs = "EPSG:4326"
7070
)
71-
})
71+
}))
7272

7373
# if roi is given, filter tiles by desired roi
7474
if (.has(roi))

0 commit comments

Comments
 (0)