0

I'm trying to see all the points that are within a polygon with the sf package. It is kinda hard to reproduce my data but it looks something like this:

gefahren$geometry[1]

Geometry set for 1 feature 
Geometry type: POLYGON
Dimension:     XY
Bounding box:  xmin: 7.308872 ymin: 46.44016 xmax: 7.310491 ymax: 46.44435
Geodetic CRS:  WGS 84
POLYGON ((7.308942 46.44277, 7.308966 46.4426, ...)

geb_pers_bunk_coord_filt$geometry

Geometry set for 355 features

Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 7.25481 ymin: 46.38084 xmax: 7.471482 ymax: 46.6349
Geodetic CRS:  WGS 84
First 5 geometries:
POINT (7.413909 46.6349)
POINT (7.384119 46.63227)
POINT (7.387245 46.63427)
POINT (7.393109 46.62949)
POINT (7.391322 46.62864)

Now, if I try the solutions I found here, I always get the same error:

st_intersection(x = gefahren, y = geb_pers_bunk_coord_filt)

Error in s2_geography_from_wkb(x, oriented = oriented, check = check) : 
  Evaluation error: Found 16 features with invalid spherical geometry.
[239] Loop 0 is not valid: Edge 450 has duplicate vertex with edge 453
[385] Loop 0 is not valid: Edge 2148 has duplicate vertex with edge 2182
[491] Loop 0 is not valid: Edge 23 has duplicate vertex with edge 43
...

int <- st_touches(x = gefahren, y = geb_pers_bunk_coord_filt)

Error in s2_geography_from_wkb(x, oriented = oriented, check = check) : 
  Evaluation error: Found 16 features with invalid spherical geometry.
[239] Loop 0 is not valid: Edge 450 has duplicate vertex with edge 453
[385] Loop 0 is not valid: Edge 2148 has duplicate vertex with edge 2182

Thx for your help!

Nico Saameli
  • 321
  • 2
  • 11

0 Answers0