[R-sig-Geo] How to filter a spatial object in sf

Gabriel Gaona g@vg712 @end|ng |rom gm@||@com
Wed Jun 30 17:05:22 CEST 2021


Dear Manuel,

The spatial filtering operation depends on the type of spatial predicate.
By default it uses st_intersects, which implies that all entities that
share boundaries around the nc_smaller object will also be filtered. By
changing the predicate you can get different results. For example try with
.predicate = st_cover

Best regards
_________________________
Gabriel Gaona
Twitter/Hangouts/telegram: gavg712
https://www.researchgate.net/profile/Gabriel_Gaona

El mié, 30 jun 2021 a las 9:53, Manuel Spínola (<mspinola10 using gmail.com>)
escribió:

> I would like to retain the information stored in a larger spatial object
> for a subset of features from a smaller spatial object.  I tried a
> st_filter but I cannot achieve my goal.
>
> nc = st_read(system.file("shape/nc.shp", package="sf"))
>
> nc_smaller <- nc %>% filter(CNTY_ID %in% c(1825, 1827, 1828))
>
> nc_filter <- st_filter(nc, nc_smaller)
>
> The nc_smaller has 3 features, but the nc_filter ended with 8 features.  I
> was expecting to have on 3 features in the nc_filter.
>
>
>
> Manuel
>
>
>
>
>
> --
> *Manuel Spínola, Ph.D.*
> Instituto Internacional en Conservación y Manejo de Vida Silvestre
> Universidad Nacional
> Apartado 1350-3000
> Heredia
> COSTA RICA
> mspinola using una.cr <mspinola using una.ac.cr>
> mspinola10 using gmail.com
> Teléfono: (506) 8706 - 4662
> Personal website: Lobito de río <
> https://sites.google.com/site/lobitoderio/>
> Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>
>
>         [[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
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list