Skip to content

Implement Affine.from_shapely classmethod #129

@kopytjuk

Description

@kopytjuk

Hey guys, first of all, thanks for the library, it is really well documented and has a nice API!

I often work with rasterio (where affine.Affine) is heavily used and also with shapely - since we have a to_shapely() method, would it make sense to implement a from_shapely() constructor? Ofc, I can contribute, it just makes the interoperability between two libarary families easier.

I am aware that it is just a very simple function, but it just avoids the mental hassle with writing the indices

def transform_shapely_order_to_affine(shapely_transform: tuple[float]) -> Affine:

    # shapely (a,b,d,e,xoff,yoff) order
    return Affine(shapely_transform[0], shapely_transform[1], shapely_transform[4], shapely_transform[2], shapely_transform[3], shapely_transform[5])

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions