[pdal] writers.gdal produces "corrupt" PNGs?

Howard Butler howard at hobu.co
Mon Jul 31 10:24:40 PDT 2017


There's a ticket to improve PDAL's writers.gdal to support more options and output data types. That will make things work better, but the development hasn't happened quite yet.

Stick with outputting GeoTIFF for now and then do gdal_translate/gdalwarp as you need as Adam's describing.

https://github.com/PDAL/PDAL/issues/1497 <https://github.com/PDAL/PDAL/issues/1497>

Howard

> On Jul 30, 2017, at 11:28 PM, Adam Steer <Adam.Steer at anu.edu.au> wrote:
> 
> Hi all
> 
> finally got to some testing with this.
> 
> Input: a LAS tile
> Expected outputs: PNG files showing grayscale images of point attributes, gridded according to some input parameters about cell sizing
> 
> I think what happens here is that PNG expects 3 bands, and I’m trying to make greyscale images. After a lot of trying GDAL options, I ended up just writing out a GeoTIFF and then using gdal_translate to carve out my PNGs, eg:
> 
> {
> "pipeline": [
>  “/path/to/tile.las",
> {
>   "type": "filters.range",
>   "limits": "Classification[2:2]"
> },
> {
>   "type": "writers.gdal",
>   "resolution": 2.0,
>   "radius": 2.5,
>   "gdaldriver":"GTiff",
>   "filename": “tile.tif",
>   "output_type": "mean,idw,count"
>   }
>   ]
> }
> 
> …and then:
> gdal_translate ./tile.tif mean_tile.png -b 1 -ot Byte -of png -scale
> gdal_translate ./tile.tif idw_tile.png -b 2 -ot Byte -of png -scale
> gdal_translate ./tile.tif count_tile.png -b 3 -ot Byte -of png -scale
> 
> …which produced valid pngs which worked as expected - greyscale rasterised point data that a web browser could view.
> 
> The nearest pipeline I could think of to generate a single writers.gdal ‘band’ as a PNG was:
> 
> {
> "pipeline": [
>  “/path/to/tile.las",
> {
>   "type": "filters.range",
>   "limits": "Classification[2:2]"
> },
> {
>   "type": "writers.gdal",
>   "resolution": 2.0,
>   "radius": 2.5,
>   "gdalopts":"ot=PNG",
>   "gdalopts":"co=scale",
>   "gdalopts":"ot=Byte",
>   "gdalopts":"co=WRITE_METADATA_AS_TEXT=NO",
>   "gdalopts":"co=b=1",
>   "filename": “tile.png",
>   "output_type": "idw"
>   }
>   ]
> }
> 
> …but this made a really big PNG (2mb, as opposed to single band pngs using an intermediate geotiff at < 150k) which was not readable by anything on my MacOS machine.
> 
> I’d happily take pipelne corrections! Lots of guessing there, and also lots of not knowing all the GDAL tricks!
> 
> Anyway, at a pinch, going gtiff -> png is possible, maybe slower than the required purpose?
> 
> HTH
> 
> Adam
> 
> 
> 
>> On 10 Jul 2017, at 10:21 pm, Vladimir Sandoval <vladimir.sandoval at yandex.com> wrote:
>> 
>> Gents:
>> I've run it with "all" bands and get a nice, huge PNG (grayscale and it's not doing the resize), that I can open and view in Opticks but nothing else.
>> 
>> On windoze, you can drag an image into Firefox, and it will display it. Firefox says it cannot display the image "because it contains errors".
>> 
>> 
>> 
>> 08.07.2017, 23:09, "Howard Butler" <howard at hobu.co>:
>>> Vladimir,
>>> 
>>> You need to be specific about what you mean by "cannot view the PNG with Firefox...".
>>> 
>>> The output of writers.gdal with the configuration you've provided is a 2-band PNG. That's probably not what you are expecting. Presumably you will want a colorized PNG or something? In that case, write out only the idw band as a PNG, and then use a GDAL VRT plus a color interpretation to convert that to a PNG that would be viewable in a way you'd expect in Firefox.
>>> 
>>> Hope this helps,
>>> 
>>> Howard
>>> 
>>> 
>>> On Jul 7, 2017, at 9:17 PM, Adam Steer <Adam.Steer at anu.edu.au> wrote:
>>> 
>>> HI Vladimir - can you check whether a PNG with just one ‘band’ (ie ‘max’ OR ‘idw’ but not both) works?
>>> 
>>> That’s all I can think of… I actually need to test this as well :) Next week…
>>> 
>>> Cheers
>>> 
>>> Adam
>>> 
>>> 
>>> On 8 Jul 2017, at 3:18 am, Vladimir Sandoval <vladimir.sandoval at yandex.com> wrote:
>>> 
>>> Trying to make a PNG from a .laz file to display in Firefox.
>>> 
>>> {
>>>  "pipeline":[
>>>    "somefile.laz",
>>>    {
>>>     "type":"writers.gdal",
>>>      "resolution": 1,
>>>      "output_type":"idw",
>>>      "output_type":"max",
>>>       "gdalopts":"of=PNG,outsize=128 128",
>>>       "gdalopts":"co=WRITE_METADATA_AS_TEXT=NO",
>>>      "filename":"outputfile.png"
>>>    }
>>>  ]
>>> }
>>> 
>>> The pipeline runs and produces a PNG. I cannot view the PNG with Firefox, MS Paint, or Windows Photo Viewer, HOWEVER, I can open it and view it in Opticks (https://sourceforge.net/projects/opticks/).
>>> 
>>> Opticks shows a single band grey scale image, probably representative of the original .laz.
>>> 
>>> Anything I'm doing wrong here producing the "corrupted" PNG?
>>> _______________________________________________
>>> pdal mailing list
>>> pdal at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/pdal
>>> 
>>> _______________________________________________
>>> pdal mailing list
>>> pdal at lists.osgeo.org
>>> https://lists.osgeo.org/mailman/listinfo/pdal
>>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pdal/attachments/20170731/df57c99c/attachment.html>


More information about the pdal mailing list