[R-sig-Geo] Inconsistent null geometry handling in sf and terra

Edzer Pebesma edzer@pebe@m@ @end|ng |rom un|-muen@ter@de
Sun Apr 17 11:09:28 CEST 2022



On 15/04/2022 18:11, Barry Rowlingson wrote:
> The `sf` package returns the extent of a null geometry as "NA", wheras
> terra's `vect` returns an object with an extent of (-180,180, -90,+90).
> `sf` also prints a warning.
> 
> This came from a gis stack Q:
> https://gis.stackexchange.com/questions/428925/sfst-read-and-terravect-reading-in-different-extents-from-the-same-shape/428983?noredirect=1#comment699839_428983
> which has link to sample data and code.
> 
> There's a few questions remaining which might be worth discussing here
> before deciding if any package needs an issue/bugfix:
> 
> 1. what does the SF standard say about the extent of a Null geometric
> feature?

"simple feature access" doesn't mention extent at all, neither as an 
operation, nor as a property.

> 2. what does the SF standard say about the extent of a collection of
> features, if one of them is Null? The `sf` package returns the extent of
> the non-null features, but there's maybe an argument for saying "if I don't
> know the extent of feature 23, I don't know the extent of any data frame
> with feature 23 in it" (by analogy with NA+1+2+3 => NA)

it doesn't say anything about properties of sets of geometries either. 
The empty geometry however is intended (as far as I understand) as the 
"no points for which" geometry, resulting for instance from the 
intersection operation on two non-intersecting geometries. It then makes 
sense, IMO, to discard it for extends; if you would propagate it like an 
NA in arithmetic ops, it would have to mean something like "a point that 
can have any coordinates" (exists, don't know where), which is not intended.

> 3. should warnings be printed when null geometries occur (terra::vect
> doesn't do this, st_read does).

You mean upon reading - I think sf prints it in the summary header, but 
does it warn?

> 
> 
> Barry
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081



More information about the R-sig-Geo mailing list