marineenergy / apps

shiny apps for MHK-env
https://marineenergy.github.io/apps/
MIT License
3 stars 1 forks source link

spatial `ocs-lease-blk`: topology error: Self-intersection at ... #71

Closed bbest closed 2 years ago

bbest commented 2 years ago

When running the intersection on a problematic input spatial dataset:

get_spatial_intersection(dataset_code='ocs-lease-blk', aoi_wkt='POLYGON ((-128.3687 31.86402, -128.3687 49.68904, -116.5255 49.68904, -116.5255 31.86402, -128.3687 31.86402))')

Got error:

Warning: Error in : Problem with `mutate()` column `sp_data`.
ℹ `sp_data = map(code, get_spatial_intersection, aoi_wkt = aoi_wkt)`.
x Failed to fetch row: ERROR:  lwgeom_intersection: GEOS Error: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -179.95155358242297 47.850116156353714 at -179.95155358242297 47.850116156353714
bbest commented 2 years ago

Fixed by updating to select_sql for dataset row ocs-lease-blk in spatial | marineenergy.app - Google Sheet to using ST_MakeValid() for problematic shapefile, per #55 and commit https://github.com/marineenergy/apps/commit/c263b168d0ff885aec832f6c552036f445c01a1a:

-- ...
select prot_numbe, prot_aprv_, block_numb, blk_fed_ap, mms_region, mms_plan_a, ST_MakeValid(geometry) AS geometry from "shp_AK_BLKCLP")