Changeset: fec8aa18d67b for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fec8aa18d67b Modified Files: sql/test/sciql/Tests/teleios_noa_bsm.sql Branch: sciql Log Message:
some corrections while trying to run the queries one-by-one diffs (122 lines): diff --git a/sql/test/sciql/Tests/teleios_noa_bsm.sql b/sql/test/sciql/Tests/teleios_noa_bsm.sql --- a/sql/test/sciql/Tests/teleios_noa_bsm.sql +++ b/sql/test/sciql/Tests/teleios_noa_bsm.sql @@ -1,64 +1,66 @@ -DECLARE size_x INT, size_y INT; -SET size_x = $img_len; -SET size_y = $img_hei; +SET SCHEMA rs; --- Assuming the TIFF images have been imported as the following: +-- Assuming these example TIF images are stored in /tmp +-- The orthorectified images need the GDAL functions attach2() and import2() +CALL rs.attach2('/tmp/img1_b3.tif'); +CALL rs.attach2('/tmp/img1_b4.tif'); +CALL rs.attach2('/tmp/img1_b7.tif'); + +CALL rs.attach2('/tmp/img2_b3.tif'); +CALL rs.attach2('/tmp/img2_b4.tif'); +CALL rs.attach2('/tmp/img2_b7.tif'); + +CALL rs.import2(1); +CALL rs.import2(2); +CALL rs.import2(3); +CALL rs.import2(1); +CALL rs.import2(2); +CALL rs.import2(3); +-- Now the TIF images have been imported as the following: -- the b3, b4 and b7 of the 1st image as rs.image1, rs.image2 and rs.image3 -- the b3, b4 and b7 of the 2nd image as rs.image4, rs.image5 and rs.image6 --- Then, put the three bands of each image into one array: -CREATE ARRAY landsat5_img1 (x INT DIMENSION[size_x], y INT DIMENSION[size_y], b3 INT, b4 INT, b7 INT); -CREATE ARRAY landsat5_img2 (x INT DIMENSION[size_x], y INT DIMENSION[size_y], b3 INT, b4 INT, b7 INT); -INSERT INTO landsat5_img1 ( - SELECT img1.x, img1.y, img1.intensity AS b3, - img2.intensity AS b4, img3.intensity AS b7 - FROM rs.image1 AS img1, rs.image2 AS img2, rs.image3 AS img3 - WHERE img1.x = img2.x AND img1.x = img3.x - AND img1.y = img2.y AND img1.y = img3.y); -INSERT INTO landsat5_img2 ( - SELECT img4.x, img4.y, img4.intensity AS b3, - img5.intensity AS b4, img6.intensity AS b7 - FROM rs.image4 AS img4, rs.image5 AS img5, rs.image6 AS img6 - WHERE img4.x = img5.x AND img4.x = img6.x - AND img4.y = img5.y AND img4.y = img6.y); +DECLARE size_x INT, size_y INT; +SET size_x = (SELECT MAX(x) + 1 FROM rs.image1); +SET size_y = (SELECT MAX(y) + 1 FROM rs.image1); -- BSM classification (landsatFirePredicate()) using one image CREATE ARRAY fire1 (x INT DIMENSION[size_x], y INT DIMENSION[size_y], f INT DEFAULT 0); INSERT INTO fire1 ( - SELECT x, y, 1 - FROM landsat5_img1 - WHERE b3 <> 0 AND b4 <> 0 AND b7 <> 0 - AND b4 <= 60 -- indexNIR - AND FLOOR(CAST(b3+b4 AS DOUBLE)/2.0) <= 50.0 -- indexALBEDO - AND b4 + b7 <> 0.0 - AND (CAST(b4-b7 AS DOUBLE)/(b4 + b7) + 1.0) * 127.0 <= 126.0 -- indexNBR, 255.0/2.0=127.0 + SELECT b3.x, b3.y, 1 + FROM rs.image1 AS b3, rs.image2 AS b4, rs.image3 AS b7 + WHERE b3.intensity <> 0 AND b4.intensity <> 0 AND b7.intensity <> 0 + AND b4.intensity <= 60 -- indexNIR + AND b3.x = b4.x AND b3.y = b4.y AND b3.x = b7.x AND b3.y = b3.y -- join the images + AND FLOOR(CAST(b3.intensity+b4.intensity AS DOUBLE)/2.0) <= 50.0 -- indexALBEDO + AND b4.intensity + b7.intensity <> 0.0 + AND (CAST(b4.intensity-b7.intensity AS DOUBLE)/(b4.intensity + b7.intensity) + 1.0) * 127.0 <= 126.0 -- indexNBR, 255.0/2.0=127.0 ); -- BSM classification (landsatFirePredicate()) using two images CREATE ARRAY fire2 (x INT DIMENSION[size_x], y INT DIMENSION[size_y], f INT DEFAULT 0); INSERT INTO fire2 ( SELECT img1.x, img1.y, 1 - FROM landsat5_img1 AS img1, landsat5_img2 AS img2 - WHERE img1.b3 <> 0 AND img1.b4 <> 0 AND img1.b7 <> 0 - AND img1.b4 <= 60 -- indexNIR_img1 - AND FLOOR(CAST(img1.b3+img1.b4 AS DOUBLE)/2.0) <= 50.0 -- indexALBEDO_img1 - AND img1.b4 + img1.b7 <> 0.0 - AND (CAST(img1.b4-img1.b7 AS DOUBLE)/(img1.b4 + img1.b7) + 1.0) * 127.0 <= 126.0 -- indexNBR_img1 - AND img1.b4 + img1.b3 <> 0.0 AND img2.b4 + img2.b3 <> 0.0 - AND ABS( CAST(img1.b4-img1.b3 AS DOUBLE)/(img1.b4 + img1.b3) - - CAST(img2.b4-img2.b3 AS DOUBLE)/(img2.b4 + img2.b3) ) > $__ndviThreshold - AND img1.x = img2.x AND img1.y = img2.y + FROM rs.image1 AS img1_b3, rs.image2 AS img1_b4, rs.image3 AS img1_b7, + rs.image4 AS img2_b3, rs.image5 AS img2_b4 + WHERE img1_b3.intensity <> 0 AND img1_b4.intensity <> 0 AND img1_b7.intensity <> 0 + AND img1_b4.intensity <= 60 -- indexNIR_img1 + AND img1_b3.x = img1_b4.x AND img1_b3.y = img1_b4.y AND img1_b3.x = img1_b7.x AND img1_b3.y = img1_b3.y -- join the images + AND FLOOR(CAST(img1_b3.intensity+img1_b4.intensity AS DOUBLE)/2.0) <= 50.0 -- indexALBEDO_img1 + AND img1_b4.intensity + img1_b7.intensity <> 0.0 + AND (CAST(img1_b4.intensity-img1_b7.intensity AS DOUBLE)/(img1_b4.intensity + img1_b7.intensity) + 1.0) * 127.0 <= 126.0 -- indexNBR_img1 + AND img1_b3.x = img2_b3.x AND img1_b3.y = img2_b3.y AND img1_b3.x = img2_b4.x AND img1_b3.y = img2_b4.y -- join the images + AND img1_b4.intensity + img1_b3.intensity <> 0.0 AND img2_b4.intensity + img2_b3.intensity <> 0.0 + AND ABS( CAST(img1_b4.intensity-img1_b3.intensity AS DOUBLE)/(img1_b4.intensity + img1_b3.intensity) - + CAST(img2_b4.intensity-img2_b3.intensity AS DOUBLE)/(img2_b4.intensity + img2_b3.intensity) ) > $__ndviThreshold ); --- BSM cloud-water mask filter ----- TODO - -- BSM majority filter DECLARE half_wsize INT; SET half_wsize = $WINDOW_SIZE/2; -- using a 3x3 or 5x5 window -CREATE ARRAY fire_marjority (x INT DIMENSION[size_x], y INT DIMENSION[size_y], f INT DEFAULT 0); +CREATE ARRAY fire_majority (x INT DIMENSION[size_x], y INT DIMENSION[size_y], f INT DEFAULT 0); CREATE VIEW neighbours AS - SELECT [x], [y], SUM(v)-v AS neighbour_cnt + SELECT [x], [y], SUM(f)-f AS neighbour_cnt FROM fire1 GROUP BY fire1[x-half_wsize:x+half_wsize+1][y-half_wsize:y+half_wsize+1]; @@ -70,6 +72,10 @@ INSERT INTO fire_majority ( AND neighbour_cnt > half_wsize ); +------------------------------------------------------------------------------- +-- above queries are tested +------------------------------------------------------------------------------- + -- BSM clump&eliminate filter CREATE ARRAY fire_eliminated (x INT DIMENSION[size_x], y INT DIMENSION[size_y], gid INT); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list