Comments (5)
After more reflection, a new (attrs) class would eliminate confusion between elements of the extent triple. Which is a real problem and solving this problem is ~half the purpose of attrs.
src_extent = Extent(width=src_width, height=src_height, transform=src_transform)
dst_extent = rasterio.warp.align_extent(rasterio.warp.get_warped_extent(
"EPSG:32618",
"OGC:CRS84",
extent=src_extent,
),
0.002
)
The class would allow fast point-in-raster tests, too.
extent = Extent(width=width, height=height, transform=transform)
col, row = ~extent.transform * (x, y)
0 <= col <= extent.width and 0 <= row <= extent.height
@groutr I think that an Extent
class might complement BoundingBox
well and resolve the ambiguity between the two concepts that has been troubling us for some time. BoundingBox
would remain 4 values (xmin, ymin, xmax, ymax)
that describe an unrotated rectangle in space. Extent
would describe a rectangle in space that could have any rotation, like the spatial footprint of a raster (data and nodata combined). #2901 could be simplified by letting the bounding box test be ignorant of rotation or north-south up orientation.
@snowman2 @vincentsarago any comments or questions?
from rasterio.
@sgillies The Extent
idea seems interesting. I want to think on it a little more, but my initial thought is what if rasterio went a step further and superseded BoundingBox with Extent? transform.array_bounds
could be used to compute the bounding box coordinates where needed.
from rasterio.
@vincentsarago Rasterio's raison d'Γͺtre is to be the best Python API for using classic raster data. Not in terms of absolute performance or number of features or format support (it's too hard to keep up with GDAL anyway), but in terms of clarity and usability. Rasterio is supposed to allow Python programmers to think less about small insignificant GDAL details. I think it's the most important thing for the project. Our North Star, to be clichΓ©.
Right now we have ambiguity about whether the bounding box is the corners points or the minimum and maximum of the corners, and that's pretty terrible. And then we have a lot of functions that take transform, height, and width as parameters or return the same three things. But in varying order! This is also terrible, entirely of my making, and something that's been bugging me for a long time. An Extent would be super useful to me and it allows new users to think less about little details.
A better name may exist, and it could wait for a 1.5.0 release. 1.4.0 has been delayed long enough already π
from rasterio.
WoW I didn't knew about aligned_target
π€― (I needed this couple weeks ago, and had to write it from scratch π
)
I fear there will be confusion between Extent and BoundingBox, and event if documented people might still use one or the other in bad ways. Maybe WarpExtent
might be less confusing π€·ββοΈ
rasterio.warp.calculate_default_transform
has been there for a long time so I guess users are use to it (I am π
) so I'm not sure to really get why we need to change it
Maybe another solution would be to add an option in calculate_default_transform
to align with a target resolution π€·ββοΈ
edit: just looking at https://github.com/search?q=calculate_default_transform&type=code there are a lot of user of this function. I agree that with 1.4
we can break things, but maybe we break things that are not working well first π
from rasterio.
I really like these ideas! In my own code I have Grid
class that contains width, height, transform, and crs. I have a reproject method that calls calculate_default_transform
and returns a new Grid
. I also have a snap_to
method that will align the Grid with particular point, not necessarily the origin. It might be nice if align_extent
would let you align with an arbitrary point.
If we're packaging height, width and transform together in an Extent class, can we make them unpackable?
from rasterio.
Related Issues (20)
- Small typo: Release 1.4a2 requires Python 3.8 instead of 3.9 HOT 1
- Test performance: Dependencies installed twice HOT 1
- `reproject` with `src_geoloc_array` introduces unexpected shift for group of pixels HOT 2
- 1.3.10 release HOT 3
- "pytest.PytestRemovedIn8Warning: Passing None has been deprecated" test failures HOT 1
- Run pyupgrade on code
- Writing a COG to a file-like object in "wb" mode fails in 1.4a2 HOT 4
- Disallow rotated rasters in merge() HOT 3
- Add correct python syntax highlighting to README HOT 2
- update_tags does not work for special tags like PIXEL_OR_AREA HOT 2
- Boundless mask reads are incorrect for complex data and GDAL 3.8
- rasterio.merge.merge() uses ~10 times more memory than specified by `mem_limit` HOT 1
- Unexpected sieve results when mask is entirely false
- Opener registration error for files in same parent directory HOT 9
- access Sentinel-1 IW SLC tiff measurement via S3 on creodias entrypoint
- memory doesn't free using features.geometry_mask function with fastapi HOT 2
- Typo in WarpedVRT's docstring
- Colormap extended to 255 HOT 3
- GDAL Error Reported in logs, but rasterio method never returns HOT 1
- rasterio.merge.merge ungracefully handles rasters with postive height or negative width HOT 2
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 rasterio.