[Thread Prev][Thread Next][Index]

Re: [ferret_users] ASCII read issues



Hi-
There are tools for translating files, which might be an even better solution. Looking around the Unidata NetCDF site, here is a list of tools that work with netCDF data.

http://www.unidata.ucar.edu/software/netcdf/software.html

This software,
http://www.unidata.ucar.edu/software/netcdf/software.html#GDAL

has a tool to translate arcAscii files to netCDF.  I do not have this on my system and have not tried it, but it might be worth looking at.  The link from the Unidata software page is out of date. It should be http://www.gdal.org/gdal_translate.html

In any case, once you have the data in a netCDF file you can use

yes? USE/order=x-y  treecover.nc

to reverse the Y coordinates

Ansley


On 10/21/2011 12:14 PM, Sam Rabin wrote:
I need to use the AVHRR tree cover classification data available at http://glcf.umd.edu/data/treecover/data.shtml, and so I downloaded the ASCII file for each continent. I have tried all day to import them, but the best I've been able to do is a severely distorted map. The good news is that all continents seem to be distorted the same way. I'll use Africa as an example (ftp://ftp.glcf.umd.edu/glcf/Continuous_Fields_Tree_Cover/Africa/af-latlong-treecover/af-latlong-treecover.grd.gz).

Here is the header to the Africa ASCII file:
ncols         9955 
nrows         9561 
xllcorner     -26.375000000000              
yllcorner     -41.500000000000              
cellsize      0.008333333333                
NODATA_value  −9999

(It looks like they actually use 0 instead of −9999 as a missing value.)

Here is the script I used for the Africa file… I calculated the endpoints of the axes as endpoint = beginning + (#cells)*0.008333. (You may need to increase available memory.)

define axis/X=26.375W:56.584E:0.0083333333/unit=degree xlong
define axis/Y=41.5S:38.175N:0.0083333333/unit=degree ylat
define grid/X=xlong/Y=ylat defries_africa_grid
file/grid=defries_africa_grid/var="TREECOVER"/columns=9955/skip=6 af-latlong-treecover.grd
define axis/X=26.375W:56.584E:0.5/unit=degree xlong2
define axis/Y=41.5S:38.175N:0.5/unit=degree ylat2
define grid/X=xlong2/Y=ylat2 defries_af_05grid
define variable/title="Defries Africa treecover regridded to 0.5 degree" africa = treecover[d=1,g=defries_af_05grid@ave]
save/clobber/file="treecover.nc" africa

The result is attached (africa_1.jpg). Playing around with the image reveals that (a) the left border should actually be around where it says 30ºE (i.e., if you cut out everything right of that and paste it onto the left side of what remains, you get something that looks better), (b) it should be flipped vertically (i.e., over the horizontal axis), and [c] that even doing those transformations, it's still pretty distorted (see africa_2.jpg, attached).

I've tried several different permutations — including adding order=yx into the fourth command — but they all ended up looking worse. This may be an issue with the dataset, but I'm more willing to believe the error lies with this end-user.

Thanks in advance.

Sam Rabin
     Graduate student
         Princeton University
         Ecology & Evolutionary Biology





[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement