marineenergy / apps

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

spatial bonks on `oil-gas-lease` w/ self-intersection #100

Open bbest opened 2 years ago

bbest commented 2 years ago

Eg for full USA without tags get error:

image

Then inspecting latest log in /var/log/shiny-server:

get_spatial_intersection(dataset_code='oil-gas-lease', aoi_wkt='POLYGON ((-165.5718 5.996829, -165.5718 62.37497, -30.61896 62.37497, -30.61896 5.996829, -165.5718 5.996829))')
Warning: Error in : Problem with `mutate()` column `sp_data`.
ℹ `sp_data = map(code, get_spatial_intersection, aoi_wkt)`.
✖ Failed to fetch row: ERROR:  lwgeom_intersection: GEOS Error: TopologyException: Input geom 0 is invalid: Self-intersection at or near point -18145077.229576949 2905378.9133797004 at -18145077.229576949 2905378.9133797004

Darn geometries! Self-intersection 😠

bbest commented 2 years ago

Why didn't this previous fix sort it from issue https://github.com/marineenergy/apps/issues/70?

select
        prot_numbe as protraction_num, 
        prot_aprv_ as protraction_aprv, 
        block_numb as block_num, 
        blk_fed_ap::date as block_fed_aprv, 
        mms_region, 
        mms_plan_a as mms_plan_area, 
        geometry
from (
        select
                prot_numbe, prot_aprv_, block_numb, blk_fed_ap, mms_region, mms_plan_a, geometry
        from shp_blk_clip
        UNION
        select
                prot_numbe, prot_aprv_, block_numb, blk_fed_ap, mms_region, mms_plan_a, geometry
        from "shp_PC_BLK_CLIP"
        UNION
        select 
                prot_numbe, prot_aprv_, block_numb, blk_fed_ap, mms_region, mms_plan_a, geometry
        from "shp_ATL_BLKCLP"
        UNION
        select
                prot_numbe, prot_aprv_, block_numb, blk_fed_ap, mms_region, mms_plan_a, ST_MakeValid(geometry) AS geometry
        from "shp_AK_BLKCLP")