-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CIMIS Mobile info. Added Preliminary Zones Map.
- Loading branch information
Showing
5 changed files
with
361 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
*.tif binary | ||
*.mp4 binay | ||
*.mp4 binay export-ignore | ||
Makefile export-ignore | ||
.git* export-ignore | ||
*.sql export-ignore | ||
*.mk export-ignore | ||
classifications/ export-ignore | ||
fft/ export-ignore | ||
earthengine/ export-ignore | ||
shp/ export-ignore | ||
src/ export-ignore | ||
station_comparisons/ export-ignore | ||
tif/ export-ignore | ||
zone_nums.csv export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
-- This SQL creates the required json for calculating the daily summaries by | ||
-- dau and eto_zone | ||
|
||
create view keys as | ||
with g as ( | ||
select | ||
510 as ncols, | ||
560 as nrows, | ||
-410000 as xllcorner, | ||
-660000 as yllcorner, | ||
2000 as cellsize | ||
) | ||
select | ||
pid,north,east, | ||
nrows-floor((north - yllcorner) / cellsize) ||'-'|| | ||
floor((east-xllcorner) / cellsize ) as key | ||
from g,cimis_boundary order by north desc,east asc; | ||
|
||
|
||
-- CIMIS pixels retrieved from website. | ||
create table cimis_boundary as | ||
select | ||
pid,east,north, | ||
st_setsrid(st_makebox2d( | ||
st_makepoint(east-1000,north-1000), | ||
st_makepoint(east+1000,north+1000)),3310) as boundary | ||
from raster_15avg | ||
join cimis_pixels using (pid); | ||
|
||
-- Areas for each pixel in each DAU | ||
create temp table dau_pixel_area as | ||
select pid,dau_code, | ||
st_area(st_intersection(p.boundary,d.wkb_geometry)) as area | ||
from cimis_boundary p | ||
join detailed_analysis_units d on st_intersects(p.boundary,d.wkb_geometry); | ||
|
||
create view json_index as with a as ( | ||
select pid, | ||
'DAU'||dau_code as code, | ||
(100*area/4000000.0)::integer as area | ||
from dau_pixel_area | ||
union | ||
select pid,'Z'||zone_id as code, | ||
100 as area | ||
from avg_0625.total_move_rmse_min where zones=17 | ||
), | ||
k as ( | ||
select | ||
--east,north, | ||
key, | ||
json_object( | ||
array_agg(code order by code), | ||
array_agg(area::text order by code) | ||
) as v | ||
from a join cimis_boundary using (pid) | ||
join keys using (pid) | ||
where area > 5 | ||
group by key | ||
order by key) | ||
select ('{'||string_agg('"'||key||'":'||v,',')||'}')::jsonb as index from k; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- From the import of Mui's final zones table..... | ||
-- The 1 byte id is p0*25. Or p0 ~ zone_number/25 | ||
alter table final_zones add column zone_number integer; | ||
update final_zones set zone_number = (p0*25)::integer; | ||
|
||
create table final_zones_rast as | ||
with t as ( | ||
select rast | ||
from avg_0625.zones_map | ||
limit 1 | ||
), | ||
v(t,b,e) as ( | ||
values (ARRAY['8BUI','32BF','32BF','32BF','32BF','32BF'], | ||
ARRAY[ | ||
ROW(null,'8BUI',0,0), | ||
ROW(null,'32BF',0,0), | ||
ROW(null,'32BF',0,0), | ||
ROW(null,'32BF',0,0), | ||
ROW(null,'32BF',0,0), | ||
ROW(null,'32BF',0,0)]::addbandarg[], | ||
ARRAY[0.0,0,0,0,0,0]) | ||
), | ||
r as ( | ||
select | ||
st_union(st_asRaster(geom,rast,t, | ||
ARRAY[(p0*25)::integer::float,p0,p1,p2,h1,h2],e)) as rast | ||
from final_zones,t,v | ||
), | ||
tot as ( | ||
select st_addBand(rast,b) as rast from t,v | ||
union | ||
select rast from r | ||
) | ||
select st_union(rast) as rast | ||
from tot; | ||
|
||
create table final_zones_pixels as | ||
with f as ( | ||
select (st_pixelascentroids(rast,1)).* | ||
from final_zones_rast | ||
), | ||
p as ( | ||
select st_x(geom) as east,st_y(geom) as north,val | ||
from f | ||
) | ||
select | ||
pid,east,north,val | ||
from p | ||
left join cimis_boundary | ||
using (east,north); | ||
|