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
Account for the antimeridian. #322
Conversation
In tests/test_io_cogeo.py bbox = (
-56.624124590533825,
73.52687881825946,
-56.530950796449005,
73.50183615350426,
) Dose In GeoJSON, bbox is [leftlon, bottomlat, ritghtlon, toplat]. In some libraries, bbox is treated as [minlon, minlat, maxlon, maxlat]. What is the stance of |
I'll try to have a look at this PR later this week 🙏 nice catch @yonda-yonda ref: https://github.com/mapbox/rasterio/blob/master/rasterio/coords.py#L5 |
Thanks @vincentsarago! bbox = (
-56.624124590533825,
73.50183615350426,
-56.530950796449005,
73.52687881825946,
) And, fix other test failures too before your review. |
add import.
@@ -14,6 +14,15 @@ | |||
MAX_THREADS = int(os.environ.get("MAX_THREADS", multiprocessing.cpu_count() * 5)) | |||
|
|||
WEB_MERCATOR_CRS = CRS.from_epsg(3857) | |||
WEB_MERCATOR_OPP_CRS = CRS.from_string( |
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.
I'm not sure to understand why this is needed?
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.
It is Opposite side CRS.
For details, please see follows.
#322 (comment)
tile_coord_width: Optional[Union[int, float]] = attr.ib( | ||
default=constants.WEB_MERCATOR_COORD_WIDTH | ||
) | ||
tile_opp_crs: Optional[CRS] = attr.ib(default=constants.WEB_MERCATOR_OPP_CRS) |
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.
Not sure to understand this. I think this will make working with other TMS quite complicated 🤷♂️
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.
I too think to be quite complicated.
But, opposite side CRS was necessary to get get_vrt_transform
to calculate Affine correctly.
Line 246 in 982811a
vrt_transform, vrt_width, vrt_height = get_vrt_transform( |
Do you have a better idea?
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.
I don't have a better idea 🙁 because I yet don't fully understand the underlying need to change this (I'll comment in the issue)
if coordinate_width is not None and not _is_clockwise(xs, ys): | ||
xs = [x + coordinate_width if x < 0 else x for x in xs] | ||
return (min(xs), min(ys), max(xs) - coordinate_width, max(ys)) |
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.
Is this the only difference with rasterio? if yes I feel we should ask Sean why not add this in rasterio directly!
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.
https://github.com/mapbox/rasterio/blob/master/rasterio/warp.py#L159
In rasterio, not account for a direction of in_xs and in_ys's rotation.
So, can't decide if it's clockwise or not.
Maybe rasterio
isn't interested in direction of rotation, and the antimeridian.
To be honest @yonda-yonda, I find the solution quite complex and I yet don't fully understand the problem of rio-tiler. I understand that:
Still, rio-tiler can create tiles from a file crossing the antimeridian. I'm not saying we shouldn't improve rio-tiler, I'm just a bit worry that we over engineer this! |
It makes rio-tiler overcomplicated. |
closes #311
rasterio
transform_bounds
andcalculate_default_transform
dosen't account for the antimeridian.COGReader's
bouds
,minzoom
,maxzoom
are incorrect,reader.part
gets an extra range.So, I replaced
transform_bound
and made some minimal changes related to create tiles.Please tell me,
WEB_MERCATOR_OPP_CRS
.(I fixed tests, but couldn't improve coverage...)
Sample Landsat-8 scenes.
normal
test_landsat8("{path to}/LC08_L1TP_063014_20201118_20201119_01_RT_B3.tiff", 7,14,33)
antimeridian
test_landsat8("{path to}/LC08_L1TP_091014_20200818_20200823_01_T1_B4.tiff", 7,0,33)
Before changing,
get_vrt_transform
return large values of Affine in this case.