[Gdal-dev] GDAL vs ArcGIS raster calculator
joosthoek
jelmer.oosthoek at tno.nl
Sun Mar 16 09:45:08 EDT 2008
Hi Frank,
Thanks for your reply, I'll try it out using python. Yeay, nodata worked
using gdal_translate -nodata 0. One other question, is it also possible to
use not python but .NET?
Cheers,
Jelmer
Frank Warmerdam-2 wrote:
>
> Jelmer,
>
> The calculation appears to be correcting for 16 bit signed integer data
> that was incorrectly treated as unsigned. It also marks post-adjusted
> values of -32768 as nodata.
>
> You should be able to do something similar with a numpy python script like
> the following (which works with FWTools):
>
> #!/usr/bin/env python
>
> import gdal
> import gdalnumeric
>
> x = gdalnumeric.LoadFile('utm.tif')
>
> x_adjusted = gdalnumeric.choose( \
> gdalnumeric.greater( x, 32767 ), (x, x-65536) )
>
> x_adjusted = x_adjusted.astype(gdalnumeric.Int16)
>
> prototype_ds = gdal.Open( 'utm.tif' )
> gdalnumeric.SaveArray( x_adjusted, 'utm2.tif', prototype = prototype_ds )
>
>
> Note, this script does not set the nodata value. That could be done as
> an additional step with gdal_translate, or is left as an exercise for the
> reader. :-)
>
--
View this message in context: http://www.nabble.com/GDAL-vs-ArcGIS-raster-calculator-tp16056156p16079149.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.
More information about the gdal-dev
mailing list