Skip to content

Commit 2c8858f

Browse files
committed
replace duckspatial with terra + sf
duckspatial was causing CI/CD problems.
1 parent 3093894 commit 2c8858f

3 files changed

Lines changed: 7 additions & 30 deletions

File tree

docker/depends/pecan_package_dependencies.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"dplyr","*","modules/uncertainty","Imports",FALSE
6767
"dplyr",">= 0.8.1","modules/data.atmosphere","Imports",FALSE
6868
"dplyr",">= 1.1.2","base/db","Imports",FALSE
69-
"duckspatial","*","modules/data.land","Imports",FALSE
7069
"ecmwfr",">= 2.0.0","modules/data.atmosphere","Suggests",FALSE
7170
"ellipse","*","modules/assim.batch","Imports",FALSE
7271
"exactextractr","*","modules/assim.sequential","Suggests",FALSE

modules/data.land/DESCRIPTION

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ Imports:
2929
curl,
3030
doSNOW,
3131
dplyr,
32-
duckdb,
33-
duckspatial,
3432
dplR,
3533
foreach,
3634
fs,

modules/data.land/R/get-landiq-parcels.R

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,15 @@
77
#' @return `design_points` `data.frame` with harmonized LandIQ parcel_IDs
88
#' @export
99
get_landiq_parcel_ids <- function(design_points, parcels_file) {
10-
parcel_crs <- sf::st_layers(parcels_file)[["crs"]][[1]]
10+
parcels_vect <- terra::vect(parcels_file)
1111
pts_sf <- design_points |>
1212
dplyr::select("id", "lat", "lon") |>
1313
sf::st_as_sf(coords = c("lon", "lat"), crs = 4326) |>
14-
sf::st_transform(parcel_crs)
15-
conn <- duckspatial::ddbs_create_conn()
16-
duckspatial::ddbs_write_vector(
17-
conn = conn,
18-
data = pts_sf,
19-
name = "design_points"
20-
)
21-
duckdb::dbSendQuery(
22-
conn,
23-
glue::glue(
24-
"
25-
CREATE TABLE merged AS
26-
SELECT dp.*, p.parcel_id,
27-
FROM design_points dp
28-
LEFT JOIN ST_Read('{parcels_file}', layer='parcels') p
29-
ON ST_Within(dp.geometry, p.geom)
30-
"
31-
)
32-
)
33-
dp_with_parcels <- duckspatial::ddbs_read_vector(
34-
conn = conn,
35-
name = "merged"
36-
) |>
37-
sf::st_drop_geometry(dp_parcels) |>
38-
dplyr::right_join(design_points, by = "id")
39-
14+
sf::st_transform(sf::st_crs(parcels_vect))
15+
dp_vect <- terra::vect(pts_sf)
16+
matched <- terra::intersect(dp_vect, parcels_vect)
17+
matched_sf <- sf::st_as_sf(matched)
18+
dp_with_parcels <- design_points |>
19+
dplyr::left_join(matched_sf, by = "id")
4020
dp_with_parcels
4121
}

0 commit comments

Comments
 (0)