0

I'm trying to warp a raster to meet an exact resolution (0.0022500000000000007, -0.0022499999999999977). I've tried using the CLI to no avail.

The example in the docs is

 rio warp input.tif output.tif --dst-crs EPSG:4326 --bounds -78 22 -76 24 --res 0.1 -- -0.1

Using

rio warp Sample2.tif Resolution.tif --res 0.0022500000000000007 -- -0.0022499999999999977 --overwrite

gives the error

Usage: rio warp [OPTIONS] INPUTS... OUTPUT

Error: Invalid value for "files": Resolution.tif is not a valid input file

Moving the overwrite forward

rio warp --overwrite Sample2.tif Resolution.tif --res 0.0022500000000000007 -- -0.0022499999999999977

does the same, though sometimes it creates a "-0.0022499999999999977" file

Suggestions?

  • rio warp Sample2.tif Resolution.tif --res 0.00225 -- -0.00225 --overwrite

    Also gives

    Error: Invalid value for "files": Resolution.tif is not a valid input file

    – Hexadecimalism Feb 28 '19 at 09:27

1 Answers1

2

The 00000000000007 etc. is due to floating point representation. Just use 0.00225. And because they're the same, your command becomes

rio warp Sample2.tif Resolution.tif --res 0.00225

Or if Resolution.tif exists:

rio warp Sample2.tif Resolution.tif --res 0.00225 --overwrite

The examples in the documentation seem to be out of date. To specify different x & y resolutions, use multiple --res args according to the output of rio warp --help:

  -r, --res FLOAT                 Output dataset resolution in units of
                                  coordinate reference system. Pixels assumed
                                  to be square if this option is used once,
                                  otherwise use: --res pixel_width --res
                                  pixel_height.

So the command becomes:

rio warp Sample2.tif Resolution.tif --res 0.00225 --res 0.00225 --overwrite

And in the uncommon case of a south up raster:

rio warp Sample2.tif Resolution.tif --res 0.00225 --res -0.00225 --overwrite
user2856
  • 65,736
  • 6
  • 115
  • 196
  • This unfortunately creates creates a file that is kb in size with next to no data in it from a 3.5 mb tif, which is makes no sense as the resolution is supposed to be increased. – Hexadecimalism Feb 28 '19 at 14:47
  • @Hexadecimalism use a positive Y resolution (see edit) – user2856 Feb 28 '19 at 21:08
  • I was under the impression that more headaches come from that when using it on a south-up raster. – Hexadecimalism Feb 28 '19 at 21:36
  • @Hexadecimalism South up are uncommon, I've never come across one, but in that case, use a negative Y --res which worked fine with my test data. If you are still having issues, edit your question to include rio info Sample2.tif --indent 4 output – user2856 Mar 05 '19 at 07:07