[Gdal-dev] GDAL vs ArcGIS raster calculator
Matt Wilkie
matt.wilkie at gov.yk.ca
Wed Mar 19 13:29:49 EDT 2008
Frank wrote:
>> 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. :-)
To set a nodata value without creating a new raster, see this modest
script, gdalsetnull.py:
http://code.google.com/p/maphew/source/browse/trunk/gis/gdal_extras/bin/gdalsetnull.py
cheers,
matt wilkie
--------------------------------------------
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
http://environmentyukon.gov.yk.ca/geomatics/
--------------------------------------------
joosthoek wrote:
> 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 )
>>
>>
>>
>
More information about the gdal-dev
mailing list