solaris icon indicating copy to clipboard operation
solaris copied to clipboard

[FEATURE]: Enable COG creation

Open nrweir opened this issue 5 years ago • 7 comments

Currently COGs can't be created from within solaris. I did try to implement it, but ran into an error when I tried to do so:

RasterioIOError: Read or write failed. Writing through VRTSourcedRasterBand is not supported.

This was a GDAL CPLE_-originating error. Googling around, this seems like it's not restricted to rio_cogeo, but the way writing is implemented in rio_cogeo could be the source of it. Alternatively, it could be an issue with the fact that I have both GDAL python bindings and rasterio installed in the environment. I got the same error when I just tried to run rio_cogeo.cogeo.cog_translate() directly in a Jupyter notebook on a GeoTIFF (not within the solaris functionality).

Two things I need to do to test this:

  1. create a new conda environment with no GDAL installed outside of rasterio and rio_cogeo, and see if I still have the same issue. If not, then this is likely a consequence of installing both GDAL and rasterio and we'll need to figure out how to resolve that.
  2. If the above doesn't fix the problem, submit an issue to the rio_cogeo repository.

nrweir avatar Jun 24 '19 04:06 nrweir

@nrweir I'll have a look, please feel free to tag me on any rio-tiler/rio-cogeo/rasterio issues

vincentsarago avatar Jun 28 '19 16:06 vincentsarago

started to have a look and I noticed multiple problems:

https://github.com/CosmiQ/solaris/blob/f2fe193c5d5417f58186e167fde80f8f69176b3f/solaris/tile/raster_tile.py#L357

dst_kwargs is misleading. This option should be populated with COG profile as seen in https://github.com/cogeotiff/rio-cogeo/blob/master/rio_cogeo/scripts/cli.py#L161-L175

Sadly this doesn't allow reprojection. If you really need to work in another projection you'll need to create a temporay file. Rio-cogeo as also a native --web-optimized option that will create WebMercator aligned COG (web_optimized=True + latitude_adjustment=False if working with local dataset)

FYI: here is an example how to use cog_translate outside rio-cogeo https://github.com/vincentsarago/cog-translator/blob/46499244b81bb5df044e90c47cceb4a5daeeecaa/cog_translator/init.py#L41-L66

vincentsarago avatar Jul 01 '19 19:07 vincentsarago

Thanks for this @vincentsarago. The intention wasn't necessarily to re-project - the source file should already be in that CRS (in effect the source file is a temp file) - I think I'd skimmed the cog_translate() code too quickly and thought that the --web-optimized hard-coding of CRS applied to any output, not only cases using that flag.

nrweir avatar Jul 02 '19 13:07 nrweir

@vincentsarago, have you ever thought about putting a conda package up for rio-tiler? I'm working on getting a conda build for this project and am trying to nail down the last few dependencies that I can't find in any channels.

nrweir avatar Jul 09 '19 01:07 nrweir

👋 @nrweir

have you ever thought about putting a conda package up for rio-tiler

No I never thought about this because I know almost nothing about conda. I'll open an issue on rio-tiler and rio-cogeo

vincentsarago avatar Jul 09 '19 01:07 vincentsarago

@vincentsarago thanks for the super prompt reply - I'm happy to help out with that, I've put together packages for conda-forge before.

nrweir avatar Jul 09 '19 01:07 nrweir

@nrweir excellent, yes please feel free to share any tips or open a PR 😄

vincentsarago avatar Jul 09 '19 01:07 vincentsarago