[gradsusr] Geotiffs in Grads

Jennifer Adams jma at cola.iges.org
Wed Dec 22 11:23:48 EST 2010


Nick,
If you use the following script, you can convert the data in the third  
column of 20100424_160000.dat (presumably the oil/no-oil grid) into a  
binary file. Note that dummy.ctl can be any GrADS data set, it is  
irrelevant, you just need to have some file open, and I changed the  
'oil' value from 16777215 to 1.

'open dummy.ctl'
'set gxout fwrite'
file = "20100424_160000.dat"
'set fwrite c3.dat'
row=1
while (row<=212930)
   ret = read(file)
   rc = sublin(ret,1)
   data = sublin(ret,2)
   c1 = subwrd(data,1)
   c2 = subwrd(data,2)
   c3 = subwrd(data,3)
   if (c3=16777215)
     'd 1'
   else
     'd 0'
   endif
   row = row+1
endwhile
rc = close(file)
'disable fwrite'

After you do that, this descriptor file will load that binary grid  
into GrADS:

dset ^c3.dat
xdef 535 linear 1 1
ydef 398 linear 1 1
*xdef 535 linear -1.0515988822025 175.4381134356
*ydef 398 linear -58.3371844811313 175.4013801622
title c3
undef -9.99e8
zdef 1 levels 0
tdef 1 linear 1jan0001 1dy
vars 1
c3 0 99 c3
endvars

I left the 0's in as valid data and used -9.99e8 as a missing value,  
but you could use 0 as an undef if you wanted to. The commented out  
lines for xdef and ydef reflect the values in the first and second  
columns of your original .dat file (by the way, it's not a good  
practice to give a file containing ascii a .dat extension). I don't  
know what those grid values mean -- you must figure out if or how they  
map to latitude and longitude. I couldn't figure out the geolocation  
by loading your geotiff file into Quantum GIS, a tool that will  
display a Geotiff, but it did provide this metadata: "Layer Spatial  
Reference System: +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs".

--Jennifer


On Dec 21, 2010, at 2:54 PM, Nick Heath wrote:

> Hi,
>
> Thank you both for the help!  I have found a way to convert the  
> geotiffs into gridded data.  I have attached 2 of the output files  
> after the conversion (I tried two different formats).  Now, I am a  
> bit lost on how to make a control file with this data as I am used  
> to working with Grib or netcdf.  Maybe someone could help?  In  
> the .dat file, I believe the 3 columns are Y,X, and either 0 (no  
> oil) or 16777215 for oil.  I am not sure why the converter picked  
> that number.  Thanks an advance for the help!
>
> -Nick
>
> ----- Original Message -----
> From: Jennifer Adams <jma at cola.iges.org>
> Date: Tuesday, December 21, 2010 10:48 am
> Subject: Re: [gradsusr] Geotiffs in Grads
> To: GrADS Users Forum <gradsusr at gradsusr.org>
>
>> Hi, Nick --
>> What you are asking for is a 'dtype geotiff' which does not exist
>> in
>> GrADS. Turning the information in a geotiff file into a grid of
>> values
>> that you can analyze with GrADS is a job for customized stand-alone
>>
>> code. You may find some useful utilities to help you get started in
>>
>> the libgeotiff distribution.
>> --Jennifer
>>
>>
>> On Dec 21, 2010, at 10:29 AM, Nick Heath wrote:
>>
>>> Hi everyone,
>>>
>>> I am working with oil spill data, and I need a way to display the
>>
>>> oil in my model.  I have geotiffs of the oil locations and I was
>>> wondering if there is any way to read those into Grads.  I also
>> have
>>> the locations in .gif files.  If that is not possible, does
>> anyone
>>> have any good ideas of how I could make a "blob" of oil that I
>> could
>>> apply equations to (such as a wind drift to watch how it moved
>>> through time)?
>>>
>>> Here is the config of the Grads I'm using:
>>>
>>> Config: v2.0.a8 little-endian readline printim grib2 netcdf hdf4-
>> sds
>>> hdf5 opendap-grids,stn geotiff shapefile
>>> Grid Analysis and Display System (GrADS) Version 2.0.a8
>>> Copyright (c) 1988-2010 by Brian Doty and the
>>> Institute for Global Environment and Society (IGES)
>>> This program is distributed WITHOUT ANY WARRANTY
>>> See file COPYRIGHT for more information.
>>>
>>> Built Fri Mar 26 10:24:10 EDT 2010 for x86_64-unknown-linux-gnu
>>>
>>> This version of GrADS has been configured with the following
>> options:>  o Built on a LITTLE ENDIAN machine
>>> o Athena Widget GUI DISABLED
>>> o Command line editing ENABLED
>>>     http://tiswww.case.edu/php/chet/readline/rltop.html
>>> o printim command for image output ENABLED
>>>     http://www.zlib.net
>>>     http://www.libpng.org/pub/png/libpng.html
>>>     http://www.libgd.org/Main_Page
>>> o GRIB2 interface ENABLED
>>>     http://www.ijg.org
>>>     http://www.ece.uvic.ca/~mdadams/jasper
>>>     http://www.nco.ncep.noaa.gov/pmb/codes/GRIB2
>>>     g2clib-1.1.8
>>> o NetCDF interface ENABLED
>>>     http://www.unidata.ucar.edu/software/netcdf
>>>     netcdf 4.1.1-rc2 of Mar 23 2010 09:31:58 $
>>> o OPeNDAP gridded data interface ENABLED
>>> o OPeNDAP station data interface ENABLED
>>>     http://iges.org/grads/gadoc/supplibs.html
>>>     libgadap 2.0
>>> o HDF4 and HDF5 interfaces ENABLED
>>>     http://hdfgroup.org
>>>     HDF 4.2r3
>>>     HDF5 1.8.4
>>> o GeoTIFF and KML output ENABLED
>>>     http://www.libtiff.org
>>>     http://geotiff.osgeo.org
>>> o Shapefile interface ENABLED
>>>     http://shapelib.maptools.org
>>>
>>> Thanks for the help!
>>>
>>> Nick
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>> --
>> Jennifer M. Adams
>> IGES/COLA
>> 4041 Powder Mill Road, Suite 302
>> Calverton, MD 20705
>> jma at cola.iges.org
>>
>>
>>
>>
> < 
> 20100424_160000 
> .zip 
> ><20100424_160000.asc>_______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr

--
Jennifer M. Adams
IGES/COLA
4041 Powder Mill Road, Suite 302
Calverton, MD 20705
jma at cola.iges.org



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20101222/059245ee/attachment-0003.html 


More information about the gradsusr mailing list