Skip to content

Commit b9436af

Browse files
committed
fix bug in st_interpolate_aw()
1 parent 064661c commit b9436af

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# version 1.0-20
22

3+
* `st_interpolate_aw()` fixes bug when a GEOMETRYCOLLECTION contains multiple POLYGON structures; found by @mtennekes
4+
35
* `st_buffer()` for geodetic coordinates allows `max_dist` and `min_level`
46
to be specified by feature; #2488 and https://github.com/r-spatial/s2/pull/264
57

R/aggregate.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ st_interpolate_aw.sf = function(x, to, extensive, ..., keep_NA = FALSE, na.rm =
133133

134134
# https://stackoverflow.com/questions/57767022/how-do-you-use-st-interpolate-aw-with-polygon-layers-that-legitimately-include-p
135135
gc = which(st_is(i, "GEOMETRYCOLLECTION"))
136-
i[gc] = st_collection_extract(i[gc], "POLYGON")
136+
# i[gc] = st_collection_extract(i[gc], "POLYGON") ## breaks if there are several POLYGONs in a GC
137+
i[gc] = do.call(c, lapply(i[gc], function(x) st_sfc(st_union(st_collection_extract(x, "POLYGON")))))
137138
two_d = which(st_dimension(i) == 2)
138139
i[two_d] = st_cast(i[two_d], "MULTIPOLYGON")
139140

0 commit comments

Comments
 (0)