go-spatial / atlante

9 stars 3 forks source link

Research how to get bbox's for Adjoining sheet given an mgd_id #118

Closed gdey closed 4 years ago

gdey commented 4 years ago

Given an mgd_id and a database of sheets to bounds data.

Get the bounding box's of the following:

  1. Bounds of the mgd_id requested
  2. Bounds and mgd_id's of the surrounding neighbors (adjoining sheets)
  3. bounds of the all the surrounding neighbors.
gdey commented 4 years ago

SQL to get adjoing sheets for an mgd_id:

select mdg_id, wkb_geometry
from public.tlm_50_index
WHERE mdg_id != 'M758G39354' and wkb_geometry && (
    SELECT ST_Expand(ST_Extent(wkb_geometry),0.01) AS expanded 
    FROM public.tlm_50_index
    where mdg_id like 'M758G39354'
)
gdey commented 4 years ago

SQL to get the bounds for the 9-sheets:

select ST_SetSRID(ST_Extent(wkb_geometry),4326) as bounds
from public.tlm_50_index
WHERE mdg_id != 'M758G39354' and wkb_geometry && (
    SELECT ST_Expand(ST_Extent(wkb_geometry),0.01) AS expanded 
    FROM public.tlm_50_index
    where mdg_id like 'M758G39354'
)
gdey commented 4 years ago

SQL to get the cutout for oceans/lakes/coastlines, etc...:

select ST_INTERSECTION(b.bounds,wkb_geometry)
--select ogc_fid, ST_ASText(wkb_geometry)
from oceans, (
select ST_SETSRID(ST_Extent(wkb_geometry),4326) as bounds
from public.tlm_50_index
WHERE mdg_id != 'M758G39354' and wkb_geometry && (
    SELECT ST_Expand(ST_Extent(wkb_geometry),0.01) AS expanded 
    FROM public.tlm_50_index
    where mdg_id like 'M758G39354'
)
) AS b
WHERE wkb_geometry && b.bounds