Skip to content

Add string representation for rio accessor#911

Open
remi-braun wants to merge 8 commits intocorteva:masterfrom
remi-braun:repr
Open

Add string representation for rio accessor#911
remi-braun wants to merge 8 commits intocorteva:masterfrom
remi-braun:repr

Conversation

@remi-braun
Copy link
Copy Markdown
Contributor

Adding a quick string representation for the rio accessor.

Example for /app/test/test_data/input/veris.nc

rioxarray accessor (.rio) | RasterDataset
Variables:
        Name: 'Slope'
        'Slope' attributes:
                count: 1
                crs: 4326
                rasterio_dtype: float64
                nodata: -9999.0
                transform: | 0.00, 0.00,-94.30|
| 0.00,-0.00, 42.35|
| 0.00, 0.00, 1.00|
                height: 50
                width: 35
                blockxsize: 35
                blockysize: 1
                bounds: (-94.30306000000002, 42.350229999999996, -94.30271000000002, 42.350730000000006)
        Name: 'Red'
        'Red' attributes:
                count: 1
                crs: 4326
                rasterio_dtype: float64
                nodata: -9999.0
                transform: | 0.00, 0.00,-94.30|
| 0.00,-0.00, 42.35|
| 0.00, 0.00, 1.00|
                height: 50
                width: 35
                blockxsize: 35
                blockysize: 1
                bounds: (-94.30306000000002, 42.350229999999996, -94.30271000000002, 42.350730000000006)

@remi-braun
Copy link
Copy Markdown
Contributor Author

This helps to quickly grasp the dataset information, a bit like printing ds.meta in rasterio

@snowman2
Copy link
Copy Markdown
Member

snowman2 commented Mar 6, 2026

I like the idea of having a string representation. However, I would like to think about how this could look like before moving forward. May be worth opening an issue to discuss.

@remi-braun
Copy link
Copy Markdown
Contributor Author

Ok I'll open one :)

@remi-braun
Copy link
Copy Markdown
Contributor Author

I added the suggestions you added in #917

Now the DataArrays look like:

    rioxarray.RasterDataArray: (y[latitude (m)]: 10, x[latitude (m)]: 10, z[band]: 1)
    Profile:
        count: 1
        crs: 32605
        dtype: float32
        nodata: 0.0
        transform:
            | 10.00, 0.00, 346860.00|
            | 0.00,-10.00, 6392220.00|
            | 0.00, 0.00, 1.00|
        height: 22547
        width: 21710
        blockxsize: 256
        blockysize: 256
        bounds: (346860.0, 6166750.0, 563960.0, 6392220.0)

And the Datasets look like:

    rioxarray.RasterDataset
    Dimensions: y[latitude (m)]: 10, x[latitude (m)]: 10, z[time]: 2
    Data variables:
        blue	y[latitude (m)]: 10, x[latitude (m)]: 10, z[time]: 2
        green	y[latitude (m)]: 10, x[latitude (m)]: 10, z[time]: 2
    Profile:
        count: 2
        crs: 32722
        dtype: float64
        nodata: nan
        transform:
            | 3.00, 0.00, 466266.00|
            | 0.00,-3.00, 8084700.00|
            | 0.00, 0.00, 1.00|
        height: 10
        width: 10
        blockxsize: 10
        blockysize: 10
        bounds: (466266.0, 8084670.0, 466296.0, 8084700.0)

Co-authored-by: Alan D. Snow <alansnow21@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants