-
Notifications
You must be signed in to change notification settings - Fork 16
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
(Un)wrapping of DEM tiles across dateline #50
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Here are two examples that include typical resampling for square resolution cells at these higher latitudes: aleutian_example_l.tif Unfortunately, QGIS has some difficulty wrapping map tiles at the dateline too. When using The rasters were generated as indicated here:
|
tags = dataset.tags() | ||
if crossing == 180 and xmax <= 0: | ||
memfile, dataset_new = translate_dataset(dataset, 360 / res_x, 0) | ||
# Ensures area or point are correctly stored! | ||
dataset_new.update_tags(**tags) | ||
elif crossing == -180 and xmin >= 0: | ||
memfile, dataset_new = translate_dataset(dataset, -360 / res_x, 0) | ||
# Ensures area or point are correctly stored! | ||
dataset_new.update_tags(**tags) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copying tags from the tiles ensures rest of workflow is correct. If relevant tags are not present, the tiles are assumed to have AREA
tag and there will be a nefarious half pixel shift. I realized this when I made an (embarrassing) post on the Affine library and Sean Gillies very nicely responded indicating that I was not writing down the affine transformation correctly.
@pytest.mark.integration | ||
def test_stitcher_across_dateline_approaching_from_left_and_right(): | ||
bounds_l = [-181, 51.25, -179, 51.75] | ||
X_l, p_l = stitch_dem(bounds_l, 'glo_30', dst_ellipsoidal_height=False, dst_area_or_point='Point') | ||
|
||
bounds_r = [179, 51.25, 181, 51.75] | ||
X_r, p_r = stitch_dem(bounds_r, 'glo_30', dst_ellipsoidal_height=False, dst_area_or_point='Point') | ||
|
||
# Metadata should be the same after translation | ||
res_x = p_r['transform'].a | ||
p_r_t = translate_profile(p_r, -360 / res_x, 0) | ||
|
||
# Georefernencing | ||
assert p_r_t['crs'] == p_l['crs'] | ||
assert p_r_t['transform'] == p_l['transform'] | ||
|
||
# Arrays should be the same as well | ||
assert_almost_equal(X_r, X_l, 5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demonstrates that approaching Aleutians from the left of the globe or the right provides identical arrays and the same geo-metadata after translation through the stitch_dem
API.
Solves #47 by (un)wrapping DEM tiles and geoid when extents cross anti-meridian / dateline.