<div dir="ltr"><div><div><div><div><div>After almost 27 hours of processing I finally have a result which looks good in MapWindow.<br></div>I did however noticed that the 'normal' translate-addOverviews process produces a tif-file with a size of 1.1GB. The original ecw is 2.6GB.<br>

</div>But when I convert the ecw using these steps to make it transparent:<br><br>echo # Make almost white pixel truly white:<br>nearblack -of GTiff -white -o white.tif my.ecw<br><br>echo Warp and mark white pixels as transparent<br>

gdalwarp --config GDAL_CACHEMAX 500 -wm 500 -multi -of GTiff -dstalpha -srcnodata "255 255 255" -co tiled=yes -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512" -s_srs EPSG:28992 -r lanczos -overwrite white.tif warped.tif <br>

<br>echo Compress <br>gdal_translate -of GTiff -a_srs EPSG:28992 -b 1 -b 2 -b 3 -co tiled=yes -co compress=jpeg -co photometric=YCBCR -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 --config GDAL_TIFF_INTERNAL_MASK YES warped.tif compressed.tif <br>

<br>echo nodata is black now. Make al blackish pixels black:<br>nearblack -of GTiff -o compressed-black.tif compressed.tif<br><br>echo set nodata value to black:<br>gdal_translate -a_nodata 0 compressed-black.tif compressed-nodata.tif<br>

<br>echo Add overviews<br>gdaladdo -r average --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR compressed-nodata.tif 2 4 8 16 32 64 128<br><br></div>I get a tif file with a size of 31GB!<br><br></div>When I do a gdalinfo I get this:<br>

<br>Driver: GTiff/GeoTIFF<br>Files: compressed-nodata.tif<br>Size is 100000, 80000<br>Coordinate System is:<br>PROJCS["Amersfoort / RD New",<br></div><div>[cut]<br></div><div>Origin = (149000.000000000000000,384000.000000000000000)<br>

Pixel Size = (0.100000000000000,-0.100000000000000)<br>Metadata:<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  INTERLEAVE=PIXEL<br>Corner Coordinates:<br>Upper Left  (  149000.000,  384000.000) (  5d18' 4.75"E, 51d26'45.47"N)<br>

Lower Left  (  149000.000,  376000.000) (  5d18' 5.24"E, 51d22'26.57"N)<br>Upper Right (  159000.000,  384000.000) (  5d26'42.66"E, 51d26'45.54"N)<br>Lower Right (  159000.000,  376000.000) (  5d26'42.34"E, 51d22'26.63"N)<br>

Center      (  154000.000,  380000.000) (  5d22'23.75"E, 51d24'36.13"N)<br>Band 1 Block=100000x1 Type=Byte, ColorInterp=Red<br>  NoData Value=0<br>  Overviews: 50000x40000, 25000x20000, 12500x10000, 6250x5000, 3125x2500, 1563x1<br>

250, 782x625<br>Band 2 Block=100000x1 Type=Byte, ColorInterp=Green<br>  NoData Value=0<br>  Overviews: 50000x40000, 25000x20000, 12500x10000, 6250x5000, 3125x2500, 1563x1<br>250, 782x625<br>Band 3 Block=100000x1 Type=Byte, ColorInterp=Blue<br>

  NoData Value=0<br>  Overviews: 50000x40000, 25000x20000, 12500x10000, 6250x5000, 3125x2500, 1563x1<br></div>250, 782x625<br><div><div><div><br></div><div>I don't see anything about compression.<br></div><div>Did I loose it along the way? Or is it expected to have such a large sized end result.<br>

</div><div>Because it is now so large I think I'll get into trouble when I add it to Geoserver. I hoped to use the tiff directly and not use Geoserver's pyramid plug-in.<br><br></div><div>Thanks,<br><br></div></div>

</div><div class="gmail_extra"><div>
<br>
Paul<br></div><br><div class="gmail_quote">2013/2/9 Paul Meems <span dir="ltr"><<a href="mailto:bontepaarden@gmail.com" target="_blank">bontepaarden@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="ltr"><div><div><div><div><div>Thanks Even,<br><br>The low-res option really helped. Now I can test the commands in seconds instead of hours.<br></div>I did these commands which seem to produce a tif file with overviews and correct transparency.<br>


</div>I've opened it in MapWindow for now to check. MapWindow is using GDAL to read raster files.<br><br></div>I will now convert the hi-res version and try that version in Geoserver.<br></div>Here are the commands I used:<br>


<br># Create a low-res version:<br>gdal_translate my.ecw test\lowres.tif -outsize 1% 1%<br><br></div><div># Fix the almost white pixels:<br></div><div>nearblack -of GTiff -white -o lowres-white.tif lowres.tif<div class="im">

<br><br># Warp and mark white pixels as transparent<br></div>
gdalwarp -multi -of GTiff -dstalpha -srcnodata "255 255 255" -co tiled=yes -co "BLOCKXSIZE=512" -co "BLOCKYSIZE=512" -s_srs EPSG:28992 -r lanczos -overwrite lowres-white.tif lowres-transparent.tif <br>


<br></div><div># Create internal tiles, don't use mask band because Geoserver doesn't like that:<br></div><div>gdal_translate -of GTiff -a_srs EPSG:28992 -b 1 -b 2 -b 3 -co tiled=yes -co compress=jpeg -co photometric=YCBCR -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 --config GDAL_TIFF_INTERNAL_MASK YES lowres-transparent.tif lowres-compressed.tif <br>


<br></div><div># nodata is now black, but not all pixels are truly black:<br></div><div>nearblack -of GTiff -o lowres-compressed-black.tif lowres-compressed.tif <br><br></div><div># Set the nodata value to black:<br></div>


<div>gdal_translate -a_nodata 0 lowres-compressed-black.tif lowres-compressed-transparent.tif<br><br># Add overviews<br>gdaladdo -r average --config COMPRESS_OVERVIEW JPEG --config PHOTOMETRIC_OVERVIEW YCBCR lowres-compressed-transparent.tif 2 4 8 16 32 64 128<br>


<br></div><br><div><div><div><div><div>Thanks all.<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div><br></div></font></span></div></div></div></div><div class="gmail_extra">

<span class="HOEnZb"><font color="#888888"><div>
<br>
Paul<br></div></font></span><div><div class="h5"><br><div class="gmail_quote">2013/2/9 Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Le samedi 09 février 2013 13:48:13, Paul Meems a écrit :<br>
<div>> The last days I've been trying to convert my ecw file to a GeoTiff so I can<br>
> use it in Geoserver.<br>
> The ecw is a mozaik of aerial photos.<br>
> When I do these two commands it is working in Geoserver:<br>
><br>
</div>>    - gdal_translate -of GTiff -co tiled=yes -co compress=jpeg -co<br>
<div>>    photometric=YCBCR -a_srs EPSG:28992 -co "BLOCKXSIZE=512" -co<br>
>    "BLOCKYSIZE=512" my.ecw my.tif<br>
</div>>    - gdaladdo -r average --config COMPRESS_OVERVIEW JPEG --config<br>
<div>>    PHOTOMETRIC_OVERVIEW YCBCR  my.tif 2 4 8 16 32 64 128<br>
><br>
> But I want to add a second reference layer beneath this one which is<br>
> larger. The translated ecw has white edges, so that is not looking nice.<br>
> I've asked about this before and suggested was to use a cutline. So I<br>
> create a polygon that is inside the ecw file and ran this command:<br>
><br>
</div>>    - gdalwarp -multi -cutline "clip.shp" -of GTiff -co tiled=yes -co<br>
<div>>    compress=jpeg -co photometric=YCBCR -co "BLOCKXSIZE=512" -co<br>
>    "BLOCKYSIZE=512" -s_srs EPSG:28992 -r lanczos -overwrite my.ecw<br>
> clipped.tif<br>
><br>
> When I open clipped.tif in MapWindow I can see the white edges are gone.<br>
</div>> But when I call *gdaladdo* white artifacts are back again.<br>
<br>
I'm not clear why gdaladdo would add while artifacts if clipped.tif has no<br>
more white borders (i.e. if your clipping shape is a rectangle completely<br>
inside the validity area of the ECW). Unless clipped.tif has an alpha channel,<br>
but the gdalwarp command line you showed has no -dstalpha. But that wouldn't<br>
work actually since you use JPEG YCbCr compression, which doesn't support<br>
alpha channels.<br>
<br>
A solution - provided that MapWindows supports GDAL mask bands as transparency<br>
channels - would be :<br>
<br>
# Warp and mark white pixels as transparent<br>
gdalwarp 1.tif 2.tif -dstalpha -srcnodata "255 255 255" [other_options]<br>
<br>
# Transform 2.tif as a JPEG-YCBCR-in-TIFF with an internal mask band<br>
gdal_translate 2.tif 3.tif -b 1 -b 2 -b 3 -mask 4 -co compress=jpeg -co<br>
photometric=YCBCR -co BLOCKXSIZE=512 -co BLOCKYSIZE=512 --config<br>
GDAL_TIFF_INTERNAL_MASK YES<br>
<br>
# Add overviews<br>
gdaladdo 3.tif  -r average --config COMPRESS_OVERVIEW JPEG --config<br>
   PHOTOMETRIC_OVERVIEW YCBCR  2 4<br>
<br>
> I'm now in the process of calling *nearblack* on both my.tiff and<br>
<div>> clipped.tif but I'm not sure I'm doing it right. I think I'm using the<br>
> correct commands but perhaps in the wrong order.<br>
> The ecw file isn't very large (2.6GB) but all steps take a long time,<br>
</div>> especially *nearblack *which is running for 4 hours now and is just at 10%.<br>
><br>
<br>
For the experiments, I'd encourage working with a low res extract of the ECW :<br>
gdal_translate src.ecw lowres.tif -outsize 1% 1%<br>
<div><br>
> Does anybody have some suggestions how to process the steps to convert an<br>
> ecw file which has white outside areas to a transparent tif file with<br>
> overviews?<br>
><br>
> I'm running the latest GDAL v1.10 version from Tamas on Windows Vista on a<br>
> 8GB 4core machine. Speed is not a big issue when I know the result will be<br>
> OK.<br>
<br>
</div>Another point: It is well known that warping with compression doesn't produce<br>
files with optimal size. See<br>
<a href="http://trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp#GeoTIFFoutput-" target="_blank">http://trac.osgeo.org/gdal/wiki/UserDocs/GdalWarp#GeoTIFFoutput-</a><br>
coCOMPRESSisbroken<br>
<br>
><br>
> Thanks,<br>
><br>
> Paul<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>