How to Write Data to File with Particular Dimension Values? [message #80426] |
Sat, 02 June 2012 10:41 |
John Doe
Messages: 1 Registered: June 2012
|
Junior Member |
|
|
This is a very basic question but I can't find the answer online.
I have a 2-dimensional (100x100) array holding landcover codes, and I
want to write it out to a NetCDF file so that the landcover codes are
indexed by lat/lng pairs. Right now I use just a single NCDF_VARPUT
and it works except in the resulting NetCDF file the landcover code is
indexed from 0 to 99. I guess this is because my IDL array itself is
indexed only from 0 to 99, and has no association with lat/lng pairs.
How do I write it out so that each array element is associated with a
specific lat/lng pair?
My code right now:
file_id = NCDF_CREATE('landcover.nc')
NCDF_CONTROL, file_id, /FILL
lng_id = NCDF_DIMDEF(file_id, 'lng', 100)
lat_id = NCDF_DIMDEF(file_id, 'lat', 100)
landcover_id = NCDF_VARDEF(file_id, 'landcover', [lng_id, lat_id], /
SHORT)
NCDF_CONTROL, file_id, /ENDEF
NCDF_VARPUT, file_id, landcover_id, myArray
NCDF_CLOSE, file_id
Thanks.
|
|
|