datalab-dev / graves-endocrine_surgeons

Claire Graves' 2022 collaboration to identify access to endocrine surgery centers
GNU General Public License v3.0
1 stars 1 forks source link

Duplicate vertexes #14

Closed MicheleTobias closed 2 years ago

MicheleTobias commented 2 years ago

The access_calculation.R file throws an error for the 120 minute isochrone data in the calc_access() function at the st_union() step:

Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, : Loop 0 is not valid: Edge 70 has duplicate vertex with edge 75

It seems that the union step creates a duplicated vertex, which, of course, is an invalid geometry.

MicheleTobias commented 2 years ago

st_union() makes a multipolgyon.

Possibly we want aggregate() with union=TRUE? Probably not. Merge()? Just some thoughts as I close out the day.

MicheleTobias commented 2 years ago

The problem was farther back than I initially realized. The isochrone data had invalid polygons (probably duplicate vertices... you can't have two consecutive vertices in the exact same location). Running st_make_valid() on the polygons before the st_union() resulted in no errors.