Drop llh fill values before geocoding in geolocate_uavsar - #51
Open
ZachHoppinen wants to merge 1 commit into
Open
Drop llh fill values before geocoding in geolocate_uavsar#51ZachHoppinen wants to merge 1 commit into
ZachHoppinen wants to merge 1 commit into
Conversation
geolocate_uavsar hands the raw lat and long grids to gdal.Warp as geolocation arrays. Outside the swath those grids are 0, so the suggested output extent runs from the scene all the way to lat, long 0. GDAL only skips those pixels if it honors the nodata flag on the geolocation arrays, which is version dependent. Where it does not, the output grid becomes hundreds of thousands of pixels wide, the reverse transform fails with "unable to compute output bounds" and the warp takes minutes instead of seconds. Mask the fill to NaN and compute the output bounds from the valid latitudes and longitudes, so the extent no longer depends on GDAL's nodata handling. Also fixes yRes taking the x spacing and the band loop always reading band 1. Addresses #34 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AGcA5iStDRm4rsucaH5iDz
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #34
What is going on
geolocate_uavsarwrites the raw.llhlat and long grids to tifs and hands them togdal.Warpas GEOLOCATION arrays. Outside the swath those grids are0, so unless GDAL honors the nodata flag on the geolocation arrays, the suggested output extent runs from the scene all the way to lat/long 0.Synthetic 400 x 400 scene near the Jemez site, fill left in, geolocation arrays with no nodata honored:
Case A is the reported symptom:
Too many points (529 out of 529) failed to transform, unable to compute output bounds, a 70,650 px wide grid, and no usable data. That run was at 0.001 deg;geolocate_uavsaruses 0.00005556 deg, 18x finer per axis, which is where 20 minutes comes from. Note case B, explicit bounds on their own are not enough, the fill has to come out of the arrays.Caveat on verification
On current GDAL (tested 3.11.4 and 3.12.3) the existing code already runs fine, in 0.03 s on my synthetic scene, because rasterio writes
nodata = 0on the lat/long tifs, that survives into the VRT, and modern GDAL skips those pixels when computing the extent (case E). Handling of nodata in geolocation arrays has changed over GDAL's history and was being discussed as a problem in 2019. The issue was filed against GDAL 3.0.2, and I have no GDAL older than 3.11 available to reproduce the original 20 minute run directly, so I cannot claim this closes the issue in the reporter's environment. What it does do is make the result independent of that behavior.Change
gdal.Warp, rather than letting GDAL infer the extent (case D above).yResusedspacing[0], so a non square spacing was silently ignored.GetRasterBand(1)every iteration, so a multiband input took band 1's datatype for every band.Check
End to end run of
geolocate_uavsaron a synthetic 300 x 300 scene whose first 30 rows are.llhfill, gdal 3.12.3:The extent matches the valid part of the scene and the low value is 31, the first row inside the swath, so the fill rows are dropped and nothing else is. Same output as pre-patch on this GDAL, one column narrower because the bounds now snap to the valid lat/long rather than to a nodata derived extent.
@jacktarricone if you still have the Jemez files, running this branch on them would say whether the 20 minute case is really gone on an older GDAL.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AGcA5iStDRm4rsucaH5iDz