Open rburghol opened 1 month ago
That's really interesting, I do wonder if just re-importing could fix it, but it's good to know your "short term fix" has led to PRISM being to the correct extent
Yeah @mwdunlap2004 I'd like to have taken the time to do a reimport but wanted to move forward. Also, the NLDAS2 data is also no fixed, so, we should be able to avoid those clips in future calculations.
@rburghol do you want me to look into this a bit? I'm wondering if specifying the source and destination CRS may help. There's a couple of SO posts about vaguely similar issues but in each case they had coordinate transformations not being specified. This _shouldn't__ be a problem in our case, but it's worth a try imo.
It's just weird because that gdalwarp
line was called (theoretically) for every data set
@mwdunlap2004 This of interest as it speaks to the out of memory issue that we get when we don't clip before resampling.
Query to show weird and good extents:
daymet
-select tid, st_astext(st_envelope(rast)) from dh_timeseries_weather where featureid = 617850 and varid = 1454 and extract(year from to_timestamp(tstime)) = 2001 limit 5;
POLYGON((-83.66607521306385 44.095589132351506,-73.52855441054511 44.095589132351506,-73.52855441054511 33.95806832983277,-83.66607521306385 33.95806832983277,-83.66607521306385 44.095589132351506))
select tid, st_astext(st_envelope(rast)) from dh_timeseries_weather where featureid = 617850 and varid = 1453 and extract(year from to_timestamp(tstime)) = 2001 limit 5;
POLYGON((-83.64583333330026 44.062499999995055,-41.97916666660025 44.062499999995055,-41.97916666660025 2.395833333295052,-83.64583333330026 2.395833333295052,-83.64583333330026 44.062499999995055))
select tid, st_astext(st_envelope(rast)) from dh_timeseries_weather where featureid = 617850 and varid = 1451 and extract(year from to_timestamp(tstime)) = 2001 limit 5;
POLYGON((-83.6255 44.0005,41.3745 44.0005,41.3745 -80.9995,-83.6255 -80.9995,-83.6255 44.0005))
gdalwarp -of "gtiff" -cutline $maskExtent -crop_to_cutline "${originalFile}.repro.gtiff" "${originalFile}${final_ext}"
Short term fix
update dh_timeseries_weather set rast = st_clip(dh_timeseries_weather.rast, st_envelope(tpr.rast)) from raster_templates as tpr where tpr.varkey = 'daymet_mod_daily' and varid = 1453 ;
\timing on
unfortunately so I don't have an exact figure).POLYGON((-83.64583333330026 44.062499999995055,-73.52083333329216 44.062499999995055,-73.52083333329216 33.937499999986954,-83.64583333330026 33.937499999986954,-83.64583333330026 44.062499999995055))
update dh_timeseries_weather set rast = st_clip(dh_timeseries_weather.rast, st_envelope(tpr.rast)) from raster_templates as tpr where tpr.varkey = 'daymet_mod_daily' and varid = 1451 ;
update dh_timeseries_weather set rast = st_clip(dh_timeseries_weather.rast, st_envelope(tpr.rast)) from raster_templates as tpr where tpr.varkey = 'daymet_mod_daily' and varid = 1451 and NOT (bbox = st_envelope(tpr.rast)) ;
UPDATE 385704
Time: 681315.766 ms (11:21.316)
POLYGON((-83.6255 44.0005,-73.5005 44.0005,-73.5005 34.0005,-83.6255 34.0005,-83.6255 44.0005))
Query 1: Update non-conforming bbox: