-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: issue with NLDAS not generating precip in small/coastal areas #62
Comments
@COBrogan the docs on st_clip, to my read (I could be wrong) suggest that intersection is implicit in st_clip: https://postgis.net/docs/RT_ST_Clip.html Either way, we can control that behavior in how we call st_clip, though still, the st_clip vs st_intersects could be an important distinction, but I am troubled by the image you showed. Since the Culpepper gage contains the Ruckersville gage, I would expect there to be many more cells overlapping than what you're showing -- I might just be getting confused by the image blocks tho. That said, at the every least I would expect the Culpepper gage to be less likely than the Ruckersville to have no data problems. I suspect maybe I goofed something up in the query during some recent tidy sessions. Which makes me wonder: what do the |
From @COBrogan I'll draft up some figures showing Interestingly, resampling the raster to the PRISM resolution also yielded no results. So, these figures showing the containments should help identify if something is going wrong in ST_clip or if we are facing a resolution problem: ST_Resample SQL Details
|
OK - resampling is a good idea, but I am still unclear why this is happening at Culpepper but not Ruckersville. Wonder if something is wrong with the geometry? Like self-intersection or something? The intersection algorithm is very inclusive, it literally just says there is some overlap. Oh, one question: does "fullrasterpoint" actually just mean a single raster cell value intersecting the point you specified? Plus @COBrogan I really think it is impossible that Culpepper contains no full pixels -- it's a drainage area of 468sqmi, it has to contain some 15x15km cells... maybe our projection is off, below is USGS map: |
From @COBrogan As for the potential conflicts in ST_clip for smaller watersheds, see below. Dashed blue is daymet, red is PRISM, and solid black is NLDAS. We can see that there are no NLDAS cells fully contained in the watershed so ST_clip() will not return values for NLDAS. |
OK cool, thanks for sorting that out!! @COBrogan The thing is though, fully contained is not the way it is supposed to be happening. Intersect literally just means they're boundaries cross. But, re-sampling to the smallest grid we have should do the trick. Still troubling, however, is that @ilonah22 reported getting no data values for Fredericksburg… |
I agree with your assertion, @rburghol . Maybe something else IS going on. First, while I've seen other users on SO with the same problem, I've yet to see official documentation of ST_clip() that implies this is the intended behavior. Second, the resampling failed to bring results. And, switching to daymet below, my query is returns logical results which indicates that my testing method works: SQL Code for Daymet single point extraction before/after clip
|
@rburghol ......I was using an incorrect set of coordinates. Resampling the NLDAS raster to PRISM results in me getting the same results at a given point. WIthout resampling, I get no data. Details
Taking this a step further, we can successfully get mean precipitation from the resampled raster: Details
Looking at a second watershed that has previously given us trouble brings us to usgs_ws_01669000 PISCATAWAY CREEK NEAR TAPPAHANNOCK, VA: Once again, our typical NLDAS summary method using Gage 01669000 Coverage NLDAS Precip Summary
|
Awesome @COBrogan -- that looks really encouraging!! Also we have to resample, anyway, so this is doubly great. I am curious, though, could you run your NLDS to query again and include a |
Sure, rerunning the above query for Piscataway Creek using count, I get the same warning that SQL for Count
One potential fix could be convert the rasters into polygons that represent the cell size and resolution. We would only need one copy of this polygon file for each data source. We then run all intersections/clips on the polygons and then use the extent of the polygon intersection as a mask with which to clip our rasters. I'm going to see if this gives us more logical results. |
@COBrogan I think the behavior is contained by the boundary not intersects with - do you concur? |
@COBrogan thanks for doing the |
Sounds good. I think we just need to update the
|
@COBrogan Thanks a bunch for keeping this on our radar. I just reviewed this in light of our bug discussion today and your remarks about the processing times. I realize I scooted before you could finish up and so I never found out how long it took for the Acquia Creek subwatershed resample + intersection. Can you annotate how long that took, and also did you use the
|
@rburghol I actually had to cancel my query last night. It had taken over 20 minutes and had yet to produce values. I just reran it now using only 2022 and it took about 6 minutes to run. It's just a lot of raster manipulation, given the hourly nature of NLDAS and it seems this resample function is pretty slow (or at least how I'm using it). I can try running the full dataset again and see if its like 1 or 2 hours or like even more but just projecting out, if 1 year takes 6 minutes than the full dataset is likely to take closer to 4 hours.
The bounding box for these entries to dh_timeseries_weather would be specific coverages, right? Like, in the |
@COBrogan 20km would cover it, but I'd prefer to use something determinate, rather than arbitrarily large. There are 4 functions in postgis that get at the cell size of a given raster:
I believe that if they are not already in the same projection as our coverage, we can reproject the raster before calling st_pixelwidth(), so we can say:
Alternatively, we can set the buffer distance as a variable in our configuration, and make sure that we choose wisely for each data set. |
@rburghol That makes sense to me. This methodology using the If you want to keep focusing on flushing out the Adding for documentation as I was unfamiliar with raster skew: https://en.wikipedia.org/wiki/World_file |
@COBrogan I like your division of labor. Responses to your Qs:
|
Hey @COBrogan I just had a thought: how about rather than altering If we do it that way, then later, we can come back and use the |
First try:
|
This issue has been addressed in various forms, as it is indeed a resolution issue. See #87 |
Trying to track down the issue with NLDAS not generating precip in the command: ( Originally posted by @COBrogan in #57)
The error keeps saying that all pixels in the area have the NoData value.
NOTICE: All pixels of band have the NODATA value
. But, this does not appear to be the case. If we look at a specific point within the watershed on a day in which we know there is rain in Aquia Creek for usgs_ws_01660400, we can see that NLDAS should have data for this watershed based on the full NLDAS rasters for that day. However, when we clip the raster to just the gage, the clipped raster no longer has data:SQL
This is NOT the case for Strausberg. At hydrocode usgs_ws_01634000, we can see that a specific point in the watershed shows equal rainfall in both the full and clipped rasters. This makes me think something has gone wrong with our ST_clip command, but I haven't tracked it down yet
SQL
It's clear that our clip at the very least generates a raster of the shape that we'd generally expect:
SQL
With some more research, my guess is that
ST_clip
doesn't grab partial cells from the raster - that is, it only grabs cells that are contained in the file or at least that the centroid is in. See here. My gage is in between several cells. The below image shows only the extent of the clipped raster from above on January 17th and shows that our site doesn't contain any full pixels:If I use
ST_intersection
I start to see values at our site. I imagine I would get similar results withST_DumpAsPolygons
but I'm guessing that will be computationally slow.ST_intersection
is already pretty slow based on my testing:SQL
The text was updated successfully, but these errors were encountered: