28 VIIRS - excluding overlappint detections
Single VIIRS overpass from North to South at night can be distinguishable using OrbitNumber. And Successive VIIRS overpasses have overlapping regions. To eliminate the overlapping, We will choose an overpass (i.e OrbitNumber) with a smaller satellite zenith angle for each 1-degree grid area for each day.
29 Example query
CREATE TEMP FUNCTION start_date() AS (DATE('2020-01-01'));
CREATE TEMP FUNCTION end_date() AS (DATE('2020-01-02'));
from VIIRS-AIS matching table
# Eliminate overlapping detection Single VIIRS overpass from North to South at night can be distinguishable using OrbitNumber.
# And Successive VIIRS overpasses have overlapping regions.
# To eliminate the overlapping, we will choose an overpass (i.e OrbitNumber) with a smaller satellite zenith angle for each 0.1 degree grid area for each day.
#
WITH
-AIS matching table
# VIIRSAS (
viirs_matching
SELECT
DATE(detect_timestamp) as date,
1 degree grid bin
# CAST(round(detect_lat) as INT64) as lat_bin,
CAST(round(detect_lon) as INT64) as lon_bin,
*,
FROM
-fishing-827.gfw_research.matches_raw_vbd_global_3top_v20210514`
`worldWHERE
DATE(_PARTITIONTIME) BETWEEN start_date() AND end_date()
),
table
# VIIRS AS (
viirs
SELECT
date
# Date(Date_Mscan) as date,
1 degree grid bin
# CAST(round(Lat_DNB) as INT64) as lat_bin,
CAST(round(Lon_DNB) as INT64) as lon_bin,
# OrbitNumberCAST(SUBSTR(File_DNB, 40,5) AS INT64) AS OrbitNumber,
# Satelite Zenith Angle
SATZ_GDNBO,
FROM
-fishing-827.pipe_viirs_production_v20180723.raw_vbd_global`
`worldWHERE
DATE(_PARTITIONTIME) BETWEEN start_date() AND end_date()
),
for each grid-Orbit-date
# Aggregate Satelite Zenith Angle as (
date_orbit_grid_zenith select
date,
OrbitNumber,
lat_bin,
lon_bin,0.5*(max(SATZ_GDNBO) + min(SATZ_GDNBO)) as SATZ_GDNBO,
from
viirsGROUP BY
date, OrbitNumber, lat_bin, lon_bin
),
Select smallest zenith orbit for each grid and day
# is used for eliminate overlapping area from successive orbits
# This as (
smallest_zenith_orbit SELECT
date,
lat_bin,
lon_bin,
OrbitNumber,
SATZ_GDNBO,
row_numFROM
(select
*,
ROW_NUMBER() OVER (PARTITION BY date, lat_bin, lon_bin ORDER BY SATZ_GDNBO ) AS row_num
FROM
date_orbit_grid_zenith
)WHERE
= 1
row_num
)
Extract detection only from smallest zenith orbits for each grid and day
# select
*
a.from
viirs_matching ainner join
smallest_zenith_orbit busing(date, OrbitNumber, lat_bin, lon_bin)