Re: [gdal-dev] Can block offsets ever be negative?

2023-06-01 Thread Even Rouault
Le 01/06/2023 à 20:39, Laurențiu Nicola via gdal-dev a écrit : Hello, Just a quick question: can block offsets (such as those in in GDALReadBlock or IRasterIO) ever be negative? No, this isn't allowed. Is there any format that supports that? No GDAL uses signed integers everywhere, whic

[gdal-dev] Can block offsets ever be negative?

2023-06-01 Thread Laurențiu Nicola via gdal-dev
Hello, Just a quick question: can block offsets (such as those in in GDALReadBlock or IRasterIO) ever be negative? Is there any format that supports that? GDAL uses signed integers everywhere, which is fine, but the intention isn't always clear at times. Thanks, Laurentiu Nicola___

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread Laurențiu Nicola via gdal-dev
Hi, Try saving the output into a new file. Those are "creation options". Laurentiu On Thu, Jun 1, 2023, at 20:34, afernandez wrote: > Hello Laurentiu, > The color palette is working fine. The issues seem to be caused by using > UInt16 because I changed to GDT_Byte per your suggestion and everyt

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread Laurențiu Nicola via gdal-dev
Hi Arturo, On Thu, Jun 1, 2023, at 20:41, afernandez wrote: > Hi Scott, > As I mentioned to Laurentiu, I'm still not getting the handle on how to use > overviews but will keep working at it. You don't need to do anything except create them. QGIS will use them automatically, for example (make s

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread afernandez
Hello Laurentiu, The color palette is working fine. The issues seem to be caused by using UInt16 because I changed to GDT_Byte per your suggestion and everything is so much smoother (this was an oversight of mine as I recycled a snippet from somewhere and should have paid much closer attention t

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread Scott
import os os.system([gdal command here]) On 6/1/23 10:41, afernandez wrote: Hi Scott, As I mentioned to Laurentiu, I'm still not getting the handle on how to use overviews but will keep working at it. However, this is only useful to me (and probably to other people) if they can be used from

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread afernandez
Hi Scott, As I mentioned to Laurentiu, I'm still not getting the handle on how to use overviews but will keep working at it. However, this is only useful to me (and probably to other people) if they can be used from a python script, not from the OS. Thanks, Arturo Scott wrote: As a test you can sk

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread Scott
As a test you can skip the whole python debacle and try this: gdal_translate -f COG -co COMPRESS=DEFLATE -scale 0 255 -ot Byte source.tif target.tif On 6/1/23 07:35, afernandez wrote: Hello, I'm generating a raster file with GDAL. The pseudo-code (where the raster is loaded as 'var') for th

Re: [gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread Laurențiu Nicola via gdal-dev
Hi, There are a couple of things you can try: • you seem to be scaling the data to 8-bit, but saving it as UInt16; GDT_Byte should work, yielding a 50% reduction. I didn't quite understand the comment about the color, does the palette not work with 8-bit images? • you can enable and tune compr

[gdal-dev] How to decrease file size of colored raster bands?

2023-06-01 Thread afernandez
Hello, I'm generating a raster file with GDAL. The pseudo-code (where the raster is loaded as 'var') for the colored version reads: # Initial manipulations dims = var.dimensions shape = var.shape driver_name = 'GTIFF' driver = gdal.GetDriverByName(driver_name) np_dtype = var.dtype type_code = gdal