[gdal-dev] Aggregate bands

Frank Warmerdam warmerdam at pobox.com
Fri Jun 14 08:22:13 PDT 2013


Siebe,

There are many ways to aggregate.  What do you want?  Just one band summing
each pixel stack?

Best regards,
On Jun 14, 2013 3:55 AM, "Siebe Bosch" <siebe at hydroconsult.nl> wrote:

>  Hi List,
>
> The question was originally mine. Thanks to Paul for posting it.
> Here's what I did (calling GDAL tools from VB.NET):
>
>    1. Warping the NetCDF-file to match my desired co-ordinate system and
>    crop the image.
>
>    outputFile = OutputDir & "\" & Str(OrderNum).Trim & "_NSL_" &
>    Str(i).Trim & ".nc"
>    myArgs = " -of NetCDF -dstnodata -999 -te " & Xmin & " " & Ymin & " "
>    & Xmax & " " & Ymax & "  -tr 1000 1000 -s_srs " & Chr(34) & "+proj=stere
>    +x_0=0 +y_0=0 +lat_0=90 +lon_0=0 +lat_ts=60 +a=6378.388 +b=6356.906" &
>    Chr(34) & " -t_srs " & Chr(34) & "EPSG:28992" & Chr(34) & " " & myPath & "
>    " & outputFile
>    ProcessCollection.Add(Process.Start(GDALToolsDir &
>    "\bin\gdalwarp.exe", myArgs))
>
>     2. Translating the 24 bands to .ASC
>
>    outputFile = myPath.Replace(".nc", ".asc")
>    myArgs = "-of AAIGrid -sds " & myPath & " " & outputFile  'exports all
>    24 subdatasets
>    ProcessCollection.Add(Process.Start(GDALToolsDir &
>    "\bin\gdal_translate.exe", myArgs))
>
>
> Now this results in 24 ASC rasters: outputFile.asc1, outputFile.asc2,
> outputFile.asc3 etc. through outputFile.asc24.
>
> By itself this is absolutely great because it gives me access to each
> band.
> My question however is still: how can I (1.) aggregate the values for all
> 24 bands into one band and (2.) write it to an  .ASC
>
> Thanks,
> Siebe
>
>
>
>
>
>
>
>
>
>
>
>
>
> On 14-06-13 08:04, Paul Meems wrote:
>
>    Hi Even,
>
>  I've just tried and I get this result:
> Warning 1: dimension #2 (x) is not a Longitude/X dimension.
> Warning 1: dimension #1 (y) is not a Latitude/Y dimension.
> Input file size is 257, 329
> ERROR 6: AAIG driver doesn't support 24 bands.  Must be 1 band.
>
>  So you are right, it doesn't work.
>
>  I don't need an ASCII grid, a different format is also OK. But I do need
> all bands combined/aggregated.
>  Do you have a different suggestion?
>
>  Or should I read (using Python or similar) each band/pixel and manual
> aggregate them?
>
>  Thanks,
>
>
> Paul
>
>   *Paul Meems *
> Release manager, configuration manager
> and forum moderator of MapWindow GIS.
> www.mapwindow.org
>
> Owner of MapWindow.nl - Support for
> Dutch speaking users.
> www.mapwindow.nl
>
> *
> *
>
>
> 2013/6/13 Even Rouault <even.rouault at mines-paris.org>
>
>> Le jeudi 13 juin 2013 15:54:42, Etienne Tourigny a écrit :
>> > that should be a simple as
>> >
>> > gdal_translate -of AAIGrid in.nc out.asc
>>
>>  Except that AAIGrid only supports 1-band datasets. I can't think of a
>> ASCII
>> based format that supports multi-band datasets.
>>
>> >
>> > On Thu, Jun 13, 2013 at 8:32 AM, Paul Meems <bontepaarden at gmail.com>
>> wrote:
>> > > Hi list,
>> > >
>> > > I have a netCDF file with 24 bands.
>> > > I want to create a new (ASCII) grid with the bands aggregated.
>> > > Is this possible using the gdal tools or with an existing python
>> script?
>> > >
>> > > Thanks,
>> > >
>> > > Paul
>> > >
>> > > _______________________________________________
>> > > gdal-dev mailing list
>> > > gdal-dev at lists.osgeo.org
>> > > http://lists.osgeo.org/mailman/listinfo/gdal-dev
>>
>>  --
>> Geospatial professional services
>> http://even.rouault.free.fr/services.html
>>
>
>
>
> _______________________________________________
> gdal-dev mailing listgdal-dev at lists.osgeo.orghttp://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
> --
> ---------------------------------------
> Hydroconsult
> Lulofsstraat 55, unit 47
> 2521 AL Den Haag
> The Netherlands
>
> web: http://www.hydroconsult.nl
> e-mail: siebe at hydroconsult.nl
> phone: +31(0)70 250 0580
> mobile: +31(0)6 17 682 689
> fax: +31(0)84 728 8946
> ---------------------------------------
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130614/4af6cb40/attachment.html>


More information about the gdal-dev mailing list