raster2pgsql ignoring nodata (seemingly)

Lorenzo Curcio <[email protected]> Wed, 5 Nov 2025 02:03:37 +0100
Newsgroups gmane.comp.gis.postgis
Message-ID <CANPMW424mBWthCboVKxyfseb9aiH7PHyZ=gLz3ST1NpGO3iJYQ@mail.gmail.com>
--000000000000586c640642ce8583
Content-Type: text/plain; charset="UTF-8"

Hi,

I have a float32 multiband (6) GTiff raster that I'm trying to upload
(tiled, given that it's 110162 x 51992) to a postgis database.

The vast vast majority of this raster is empty / nodata (on all 6 bands).
(it only has data for rivers and covers all of europe, any part not near a
river is nodata). The statistics_valid_percent (for all layers) is barely
above 3%. Despite that, whenever I try to run raster2pgsql with -t auto
(and _without_ -k) it will always try and produce a 100+gb sql output file,
seemingly never actually eliminating any tiles.

I have tried everything I can think of, setting and resetting the raster
nodata in tons of ways, manually passing it in via -N, it just doesn't
change anything, raster2pgsql is always writing these huge output sql files
instead of properly culling tiles (the complete lack of verbosity in
raster2pgsql is not helping here . . for instance a simple print of what it
considers the band nodata to be would answer this question, but if such an
option exists it's not documented)

Are there any ideas on what could cause this to happen or any further
debugging steps?

Sorry if this is not the right place to ask - please point me to where the
right place would be instead if so.

Thanks, Lorenzo

--000000000000586c640642ce8583
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div><br></div><div>I have a float32 multiba=
nd (6) GTiff=C2=A0raster that I&#39;m trying to upload (tiled, given that i=
t&#39;s=C2=A0110162 x=C2=A051992) to a postgis database.<br><br></div><div>=
The vast vast majority of this raster=C2=A0is empty / nodata (on all 6 band=
s). (it only has data for rivers and covers all of europe, any part not nea=
r a river is nodata). The statistics_valid_percent (for all layers) is bare=
ly above 3%. Despite that, whenever I try to run raster2pgsql with -t auto =
(and _without_ -k) it will always try and produce a 100+gb sql output file,=
 seemingly never actually eliminating any tiles.</div><div><br></div><div>I=
 have tried everything I can think=C2=A0of, setting and resetting the raste=
r nodata in tons of ways, manually passing it in via -N, it just doesn&#39;=
t change anything, raster2pgsql is always writing these huge output sql fil=
es instead of properly culling tiles (the complete lack of verbosity in ras=
ter2pgsql is not helping here . . for instance a simple print of what it co=
nsiders the band nodata to be would answer this question, but if such an op=
tion exists it&#39;s not documented)<br><br></div><div>Are there any ideas =
on what could cause this to happen or any further debugging steps?<br><br><=
/div><div>Sorry if this is not the right place to ask - please point me to =
where the right place would be instead if so.</div><div><br></div><div>Than=
ks, Lorenzo</div></div>

--000000000000586c640642ce8583--