[Gdal-dev] Re: regarding reading the NALPS NDF Data format to extract the Pixel data

Charles Wivell charles.wivell at dnr.state.mn.us
Tue Feb 7 10:16:48 EST 2006


Hi Vijay;

Are you writing the code (in C++?).... If you are, it might be just as easy to write an NLAPS reader yourself....

Just parse the header file for the information you need. (such as)

BITS_PER_PIXEL=8;
PIXELS_PER_LINE=6725;
LINES_PER_DATA_FILE=5984;
NUMBER_OF_DATA_FILES=7;
DATA_FILE_INTERLEAVING=BSQ;

There are 7 bands to this image (DATA_FILE) and they are BSQ (but not really.... each band is in its own file .I1, .I2.....)


This is Byte data, so set up a memory buffer for each band:
unsigned char *BufferBand1;
BufferBand1 = new unsigned char[6725 * 5984];

Then read the data into the buffers....

Additional header information.....
UPPER_LEFT_CORNER=1021440.9717W,0353344.8107N,205903.465,3940265.465;
UPPER_RIGHT_CORNER=1000330.0455W,0351442.0994N,403711.109,3900729.474;
LOWER_RIGHT_CORNER=1002504.2293W,0333915.2393N,368532.074,3724720.680;
LOWER_LEFT_CORNER=1023348.1216W,0335802.3159N,170724.430,3764256.671;

MAP_PROJECTION_NAME=UTM;
USGS_PROJECTION_NUMBER=1;
USGS_MAP_ZONE=14;

The corner information is just: Longitude, Latitude, Easting, Northing
The Format: Longitude: DDDMMSS.SSS(EorW), Latitude: DDDMMSS.SSS (NorS), Easting in meters, Northing in meters

PIXEL_SPACING=30.0000,30.0000;
PIXEL_SPACING_UNITS=METERS;

The size of each pixel is 30 meters by 30 meters, so to find the Easting and Northing values... For each line you move through the image,
just subtract off 30 meters from Northing of the Upper left corner and for each pixel, add 30 meters to the Easting of the Upper left corner.

To get the pixel value at a point in the image....

unsigned char PixelValue;

int PixelLocation;

PixelLoction = line * nPixelsInLine + pixel;
PixelValue = BufferBand1[PixelLocation];

USGS_PROJECTION_PARAMETERS=6378137.000000000000000,6356752.314249999800000

6378137.0 is the semi-major axis of the ellipsoid and 6356752.3142499998 is the semi-minor axis of the ellipsoid and would be needed if you want to convert Easting/Northing to lat/Lon...

If you want to convert Northing/Easting to Latitude/Longitude, you can use libraries like GCTP (which is in C), which is what I use... I converted the UTM projection routines to C++;

Hope that helps

Chuck



>>> Vijay Akkineni <akkineni.vijay at gmail.com> 02/06/06 6:09 PM >>>
HiFrank,

            I tried  to import the landsat 5 images which are in NDF Format
to grass .I am not familliar how to do that in grass . I tried doing with
r.in.gdal but i was unsucesfull . The images i have got are in the format
below...

09/10/2005  06:45 AM             2,820 LT5030036000519410.H1 <-- Header
File.
09/10/2005  06:43 AM            83,701 LT5030036000519410.HI
09/10/2005  06:43 AM        40,242,400 LT5030036000519410.I1
09/10/2005  06:43 AM        40,242,400 LT5030036000519410.I2
09/10/2005  06:44 AM        40,242,400 LT5030036000519410.I3
09/10/2005  06:44 AM        40,242,400 LT5030036000519410.I4
09/10/2005  06:44 AM        40,242,400 LT5030036000519410.I5
09/10/2005  06:44 AM        40,242,400 LT5030036000519410.I6
09/10/2005  06:45 AM        40,242,400 LT5030036000519410.I7
09/10/2005  06:43 AM            14,577 LT5030036000519410.WO
09/10/2005  06:45 AM            15,298 README.TXT

I am attaching the header file so that u can have a  look at it . Can u tell
me the procedure to do it . What i am trying to do is that i need the
information of the pixels along with latitude and longitude . How can i do
the extraction of the information . Sorry For troubling you frank.  I have
no idea about GIS.

Regards,
Vijay Akkineni.





More information about the Gdal-dev mailing list