Skip to content

Setting block(x|y)size in rio convert throws TypeError in rasterio 1.4.3 #3316

@tobijjah

Description

@tobijjah

Expected behavior and actual behavior.

Hey, rasterio maintainers, with rasterio 1.4.3 installed, setting the blockxsize or/and blockysize with the following rio convert command,

rio convert \
--overwrite \
--profile blockxsize=128 \
--profile blockysize=128 \
input.tif \
output.tif 

throws the following TypeError:

Traceback (most recent call last):
  File "/Users/USER/.pyenv/versions/3.12.2/bin/rio", line 8, in <module>
    sys.exit(main_group())
             ^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/core.py", line 1697, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/rasterio/rio/convert.py", line 85, in convert
    for chunk in subdivide(srcds, bxsize, bysize):
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/USER/.pyenv/versions/3.12.2/lib/python3.12/site-packages/rasterio/windows.py", line 816, in subdivide
    if row_off + height > irow:
       ~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for +: 'int' and 'str'

This works without any errors with rasterio 1.3.10 installed. I did not check any other versions between 1.3.10 and 1.4.3. I guess in earlier versions, the CLI input was converted to int somewhere.

Happy bug fixing, and have a nice day!

PS Thanks for your work on rasterio, I really like this package.

Steps to reproduce the problem.

Run in rasterio 1.4.3 the following rio convert command:

rio convert \
--overwrite \
--profile blockxsize=128 \
--profile blockysize=128 \
input.tif \
output.tif 

Environment Information

rasterio info:
  rasterio: 1.4.3
      GDAL: 3.9.3
      PROJ: 9.4.1
      GEOS: 0.0.0
 PROJ DATA: /Users/tobiasse/.pyenv/versions/3.12.2/lib/python3.12/site-packages/rasterio/proj_data
 GDAL DATA: /Users/tobiasse/.pyenv/versions/3.12.2/lib/python3.12/site-packages/rasterio/gdal_data

System:
    python: 3.12.2 (main, Apr 23 2024, 15:24:25) [Clang 15.0.0 (clang-1500.3.9.4)]
executable: /Users/USER/.pyenv/versions/3.12.2/bin/python3.12
   machine: macOS-15.3.1-arm64-arm-64bit

Python deps:
    affine: 2.4.0
     attrs: 25.1.0
   certifi: 2025.01.31
     click: 8.1.8
     cligj: 0.7.2
    cython: None
     numpy: 2.2.2
click-plugins: None
setuptools: 70.0.0

Installation Method

pip install --no-binary rasterio rasterio

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions