Skip to content

Commit

Permalink
add .sf_namespace attribute by default
Browse files Browse the repository at this point in the history
closes #2277
closes #2212
  • Loading branch information
edzer committed Mar 17, 2024
1 parent e2a2513 commit 67d41e4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# version 1.0-16

* unless the env. variable `ADD_SF_NAMESPACE` is set to `false`, `sf` objects contain an attribute, `.sf_namespace`, which forces loading the `sf` namespace when it has not been loaded so far, e.g. for printing or plotting of an `sf` object; #2212 by Mike Mahoney

* `st_sample()` works when unprojected polygon geometry crosses the antemeridian; #2331

* clean up and modernization of S3 registration of methods and tests; #2285, #2288, #2316, #2341, #2342, by @olivroy
Expand Down
2 changes: 1 addition & 1 deletion R/sf.R
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ st_sf = function(..., agr = NA_agr_, row.names,
if (! missing(crs))
st_crs(df) = crs

if (Sys.getenv("ADD_SF_NAMESPACE") == "true")
if (Sys.getenv("ADD_SF_NAMESPACE") != "false")
attr(df, ".sf_namespace") <- .sf_namespace

df
Expand Down
5 changes: 3 additions & 2 deletions tests/sfc.Rout.save
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ use `st_zm(...)` to coerce to XY dimensions
>
> sf_extSoftVersion()[1:3]
GEOS GDAL proj.4
"3.12.1" "3.8.3" "9.3.1"
"3.12.1" "3.8.4" "9.3.1"
>
> # Ops.sfc:
> ls = st_sfc(st_linestring(rbind(c(0,0),c(0,1))))
Expand Down Expand Up @@ -437,6 +437,7 @@ Classes 'sf' and 'data.frame': 100 obs. of 15 variables:
- attr(*, "sf_column")= chr "geometry"
- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..: NA NA NA NA NA NA NA NA NA NA ...
..- attr(*, "names")= chr [1:14] "AREA" "PERIMETER" "CNTY_" "CNTY_ID" ...
- attr(*, ".sf_namespace")=function ()
> bb = st_as_sfc(st_bbox(nc))
> format(st_bbox(nc))
[1] "((-84.32385,33.88199),(-75.45698,36.58965))"
Expand Down Expand Up @@ -1088,4 +1089,4 @@ CRS: NA
>
> proc.time()
user system elapsed
5.127 1.392 5.019
5.159 1.424 5.082

0 comments on commit 67d41e4

Please sign in to comment.