sf
sf copied to clipboard
st_as_sf() with all coordinates missing
gives an unhelpful array of warnings:
sf::st_as_sf(data.frame(a = 1, lng = NA_real_, lat = NA_real_), coords = c("lng", "lat"), na.fail = FALSE)
#> Warning in min(cc[[1]], na.rm = TRUE): no non-missing arguments to min;
#> returning Inf
#> Warning in min(cc[[2]], na.rm = TRUE): no non-missing arguments to min;
#> returning Inf
#> Warning in max(cc[[1]], na.rm = TRUE): no non-missing arguments to max;
#> returning -Inf
#> Warning in max(cc[[2]], na.rm = TRUE): no non-missing arguments to max;
#> returning -Inf
#> Simple feature collection with 1 feature and 1 field
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: Inf ymin: Inf xmax: -Inf ymax: -Inf
#> CRS: NA
#> a geometry
#> 1 1 POINT EMPTY
Created on 2021-09-20 by the reprex package (v2.0.1)
I think here, and in one or two other instances, we should internally use min()
+ max()
variants that never warn but return NA_real_
.