Giter Club home page Giter Club logo

Comments (5)

sgillies avatar sgillies commented on May 24, 2024 1

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.

groutr avatar groutr commented on May 24, 2024 1

@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.

sgillies avatar sgillies commented on May 24, 2024 1

@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.

vincentsarago avatar vincentsarago commented on May 24, 2024

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.

pblankenau2 avatar pblankenau2 commented on May 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.