Comments (14)
You might also like this re-implementation of rasterio.warp.calculate_default_transform
:
I found it to perform unconditionally better (i.e., more accurate) when round-tripping reprojections, especially at high latitudes (we had some imagery from northern Greenland). The problem is that GDAL's default transform enforces square pixels in the target CRS, which destroys information if the image gets elongated along one dimension.
from rio-tiler.
By the way, thank you for building rio-tiler
! It was a huge inspiration and I had no idea something like Terracotta could be possible before playing with it.
from rio-tiler.
prevent interpolation artefact
Maybe I can give you some background on this one. I found that rio-tiler
has some trouble with visible tile edges at high zoom levels if resampling
was set to anything else than nearest
.
If I understand the problem correctly, this occurs because the VRT ends right at the tile boundary, so the entity reading from it cannot know what lies beyond, and how it should interpolate. Padding the VRT with 2 pixels in each direction fixes the problem (if you're careful with roundoff errors). It has to be two pixels because cubic
interpolation has a bandwidth of 2, I guess.
from rio-tiler.
If I understand the problem correctly, this occurs because the VRT ends right at the tile boundary, so the entity reading from it cannot know what lies beyond, and how it should interpolate. Padding the VRT with 2 pixels in each direction fixes the problem (if you're careful with roundoff errors). It has to be two pixels because cubic interpolation has a bandwidth of 2, I guess.
I see, but if I understand this correctly, you'll need to fetch more data than actually needed ? This could be worrying in case when we have a file which is aligned with mercator grid, and it might result in fetching more internal tiles.
from rio-tiler.
That is correct. I haven't even tried to implement any shortcuts for rasters that are already aligned yet because part of the point of Terracotta is that you don't need to do any fancy preprocessing to your data (but it's definitely on my list, especially with the recent support in rio-cogeo
).
I would love to find a more elegant solution for the problem, but I don't see how that would look. The reader has to be able to "look ahead" somehow when using higher-order interpolation if you want accurate results.
On a side note, you can reduce the padding to 1 for linear interpolation and to 0 for nearest. Nearest should be accurate for rasters that are aligned until you're at sub-pixel level, so maybe we could exploit that.
from rio-tiler.
Hey @vincentsarago & @dionhaefner
I've just been having a play with the idea of reducing tile edge effects. I basically took the ideas contained within terracotta
here and applied them to rio-tiler by introducing an tile_padding
parameter.
My work is available in this fork which I'm happy to submit as a pull request if you'd like.
Below you can see some examples of two tiles next to each other rendered rendered with bilinear
sampling but with different tile_padding
settings.
- Prior is what rio-tiler currently produces
- with tile-padding=0 you are seeing my changes, and the images are exactly the same as what you currently get
- with tile-padding=2 you start seeing the improvements
- with tile-padding=4 I'm pretty sure you get the same as tile-padding=2 (presumably that's a reflection on how bilinear sampling works...)
From a library user perspective adding a flag like tile_padding
(which I'm happy to change the name of) at least allows me to specify whether I want to make the tradeoff of retrieving extra data vs the quality of the tile edges that are returned.
Anyway let me know what you think.
Cheers
Rowan
from rio-tiler.
Nice @rowanwins please feel free to submit a PR.
I wonder if we should use tile_padding=2
as default and then overwrite it to 0
if we don't need resampling (if the internal tiles match the requested bounds)
from rio-tiler.
I also wonder if this can fix #95
from rio-tiler.
Cool, will submit a pr in the next few days. Let me know if you think off a better name for the parameter.
I also want to bolster the tests a smidge too make sure it's only modifying pixels within a certain range of the tile edge.
The only other thought i had was if there was a python performance library where we could test the impact of these changes... I mostly come from js world where we use a library called benchmark.js
to measure the time impact of changes, i presume there is an equivalent in python world...
from rio-tiler.
Cool, will submit a pr in the next few days. Let me know if you think off a better name for the parameter.
Name is ok I think. Maybe tile_edges_padding
is more obvious ?
I also want to bolster the tests a smidge too make sure it's only modifying pixels within a certain range of the tile edge.
👍
The only other thought i had was if there was a python performance library where we could test the impact of these changes... I mostly come from js world where we use a library called benchmark.js to measure the time impact of changes, i presume there is an equivalent in python world...
Well I don't think it will impact the performance much, will just use a bit more data thus memory but nothing too impactful IMO.
from rio-tiler.
I'm excited to hear about this development. The padded tiles look amazing. Thanks @rowanwins!
@vincentsarago I'm curious if this feature is antithetical to the --web
optimized COGs from rio-cogeo. Just curious how requests for padded 260x260 tiles will work when the COG is optimized for 256x256 boundaries. If this is a reasonable concern, obviously this conversation would be best moved to the rio-cogeo repo.
from rio-tiler.
I'm curious if this feature is antithetical to the --web optimized COGs from rio-cogeo. Just curious how requests for padded 260x260 tiles will work when the COG is optimized for 256x256 boundaries. If this is a reasonable concern, obviously this conversation would be best moved to the rio-cogeo repo.
Yeah basically this is my only concern, if the tile bounds fits the internal tile (no need of resampling) we should overwrite tile_padding
to 0. But right now I don't know how to handle that
from rio-tiler.
Would it be reasonable to add configuration to cogeo --web
for padding? This would allow a user to generate web+padding optimized COGs when they anticipate it will be accessed from rio-tiler with tile_edges_padding
enabled.
from rio-tiler.
@DanSchoppe my first though is that we don't want tiles that are not a 64px multiple (not sure if it's possible anyway) and IMO we should always consider rio-cogeo and rio-tiler as separate entity (so don't change things in it to accommodate the other).
from rio-tiler.
Related Issues (20)
- Investigate weird output resolution after #648 HOT 3
- remove usage of WarpedVRT?
- No colormapping support for float dtype HOT 1
- Worse image quality with tiles cut using rio-tiler than GDAL HOT 4
- Custom In-Memory Reader HOT 1
- nodata value being ignored HOT 3
- .tile() is not masking region outside of image when nodata used HOT 3
- Count default method? HOT 1
- Incorrect array statistics with (coverage) weights HOT 2
- Method to filter assets within mosaic_reader HOT 1
- Forwarding `ImageData.array.mask` in NPZ output HOT 4
- [STAC] access Alternate URL
- nodata value being ignored for NaN HOT 2
- Error applying expression with STACReader : "NumExpr 2 does not support Unicode as a dtype."
- Investigate higher HEAD/GET Request with GDAL >3.7 HOT 9
- replace deprecated `is_tiled`
- S3 STAC item may not load properly after pystac 1.10 HOT 2
- Better handle Dateline crossing Dataset
- refactor benchmark
- ImportError: cannot import name 'WEB_MERCATOR_TMS' from 'rio_tiler.constants'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rio-tiler.