Comments (1)
So - I would definitely say this is a shortcoming of this library. That said, this result is currently a feature, not a bug, in that it's output is expected (by me), though it certainly could yield unexpected results for users, particularly if you are expecting a raster covering the requested extent, which many are! The issue in this case is that the bounds you requested fall outside of the what is available with glo-30
.
Globally glo-30
tiles look like this:
For the requested area (zoomed in), the yellow lines are the glo-30
tiles available and the black is the area you selected:
The latter was generated using:
from dem_stitcher import get_overlapping_dem_tiles
from rasterio.crs import CRS
import matplotlib.pyplot as plt
from shapely.geometry import box
import geopandas as gpd
bounds = [176.678207, 50.908962, 179.697601, 52.754662]
df_tiles = get_overlapping_dem_tiles(bounds=bounds,
dem_name='glo_30')
df_bbox = gpd.GeoDataFrame(geometry=[box(*bounds)], crs=CRS.from_epsg(4326))
fig, ax = plt.subplots()
df_bbox.exterior.plot(ax=ax, color='black')
df_tiles.exterior.plot(ax=ax, color='yellow')
ax.set_xlabel('Lon')
ax.set_ylabel('Lat')
So, the rounding is done because the origin and extent is selected on what's available via rasterio. It's based on window functionality (maybe inherited from gdal?): https://rasterio.readthedocs.io/en/stable/topics/windowed-rw.html.
Here is a hypothetical sample:
from shapely.geometry import box
bounds=[<BOUNDS>]
geo = box(*bounds)
with rasterio.open(<IMAGE_PATH>) as src:
out_image, out_transform = rasterio.mask.mask(src, geo, crop=True)
out_meta = src.meta
out_meta.update({"driver": "GTiff",
"height": out_image.shape[1],
"width": out_image.shape[2],
"transform": out_transform,
"compress": "lzw"})
with rasterio.open("<OUT_PATH>", "w", **out_meta) as dest:
dest.write(out_image)
I don't have sample data - but basically origin will be shifted if the requested bounds are to the left of source image similar to your example.
Hope this makes sense. At some point, it might be helpful to change the origin depending on requested data and fill with nodata, but currently, left things without additional modification because it's easier (to avoid any resampling would have to figure out origin so that it contained extent and then write the appropriate tests).
Glad you spotted this and hope this can be used in the future to highlight this deficiency of this library.
from dem-stitcher.
Related Issues (17)
- Software Versioning, ASF CI/CD HOT 1
- pip install for Python <=3.7 is v. 0.0.1 HOT 1
- Pixel shift when dst_area_or_point == 'Point' HOT 1
- Resampling and Profile Translations are Non-commutative and related Errors
- Missing glo-30 DEM tiles over Azerbaijan, Armenia
- Install via Conda-Forge
- Update ISCE2 Ingest and Clarification of how to stage DEMs HOT 1
- Add Python 3.10 Back
- Anti-meridian
- Removal of `2021` from AWS Glo Registry HOT 1
- Verification of DEM heights and Geoid removal in comparison to independent dataset HOT 1
- Access NASADEM Water Body layer (SWB) HOT 3
- edge problem? I'm getting vertical of zero pixels at tile edge here HOT 3
- BadZipFile: File is not a zip file HOT 2
- Reading tile imagery take long time in wsl (windows subsidiary linux tested os : ubuntu and debian) HOT 1
- Failed to connect to download.agisoft.com port 80 after 131945 ms: HOT 8
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 dem-stitcher.