X
42 Rate this article:
No rating

[Internal] How can I extract GPS data from my ASD binary spectrum file?

Help Article Update 2

Anonym

Topic:

While ENVI can directly import an ASD binary file into a Spectral Library, these files often contain useful ancillary information that ENVI does not import. This can include the coordinates of acquisition for the spectrum if it was acquired while a compatible GPS unit was attached to the field spectrometer. This Help Article discusses how to programmatically extract the GPS portion of the binary file using IDL.

Discussion:

ASD binary files have a very complicated internal header structure, which includes not only spectral information but also spatial information related to where the spectrum was acquired. Using IDL's READU (read unformatted binary data) procedure, it is possible to manually extract the GPS information into a structure variable for use in other ENVI or IDL user programs. The example code below will walk you through how to do this. A few things to note:

- No projection or datum information is stored, so you will have to provide this yourself if you plan to do any spatially-related processing or georeferencing of the spectra.

- While the ASD variable names for coordinates are latitude and longitude, they are essentially referring to northings and eastings. So, a latitude value of -1007864.34 is really 1007864.34 South (presumably in meters), and a longitude value of -270685.56 is really 270685.56 West (also presumably in meters).

- Depending on the GPS that was used, there might be altitude information available as well, so be sure to check that portion of the structure variable.

Solution:

pro read_asd_gps_info
	compile_opt idl2

	;Prompt user to select a valid ASD binary file
	asd_file = dialog_pickfile(title='Select ASD Binary File')
	if asd_file eq '' then return

	;Create empty structure variable for GPS data.  All values are stored
	;in double precision floating point.
	gps_info = {true_heading:0.0D, speed:0.0D, latitude:0.0D, $
		longitude:0.0D, altitude:0.0D}

	;Open the ASD file for reading, assign the first free LUN available
	openr, lun, asd_file, /get_lun

	;Force IDL to start reading the ASD file at byte address 334,
	;which is where the GPS data are stored in the header.
	point_lun, lun, 334
	
	;Read the ASD file and fill the structure with the appropriate data.	
	readu, lun, gps_info

	;Check to see if GPS data were retrieved successfully.
	print, gps_info

	;Free the LUN
	free_lun, lun

end
Company Confidential - Reviewed by CS 8/25/2014