com.c5corp.c5dem
Class Dem

java.lang.Object
  extended by com.c5corp.c5dem.Dem
Direct Known Subclasses:
DemTable

public class Dem
extends java.lang.Object

Digital Elevation Model (DEM) object

Dem encapsulates objects for each data type in a DEM file: type a, type b, type c. Type a and c are single records, and are held in variables in a TypeA and TypeC object. TypeB records (elevation profiles) are contained in a TypeBprofiles object as an array. There are N profiles per Dem file.

I have rewritten the interface a great deal and at different times. a stylistic convention I have emerged is to use shell_style method names for native DEM data elements, and humpNotation for generated metadata and other things not specified by the DEM format. I have not extended these to TypeA or TypeC.

Since:
1.0
Author:
Brett Stalbaum Copyright 2002-2006 see LICENSE.txt and UCSD_LICENSE.txt

Constructor Summary
Dem(java.io.File file)
          Constructs a DEM from an input file specified in java.io.File file
Dem(java.lang.String inputfile)
          Constructs a DEM from an input file specified in String inputfile
Dem(java.net.URL url)
          Constructs a DEM from a java.net.URL
 
Method Summary
 short get_accuracy_code()
          Returns the dem specification Data Element 14 - Accuracy code for elevations: 0=unknown accuracy, 1=accuracy information is given in logical record type C.
 short get_availability()
          Type C Data Element 4 - Code indicating availability of statistics in data element 5: 1=available, 0=unavailable
 short get_column_count()
          Convenience method for Data Element 16 the number of columns in the file is the same as the number of B records
 short get_contour_interval_l()
          Returns the dem specification Data Element 18 - Source contour interval units.
 short get_contour_interval_s()
          Returns the dem specification Data Element 20 - Source contour interval units Corresponds to the units of the map smallest primary contour interval.
 double get_counter_angle()
          Returns the dem specification Data Element 13 - Counterclockwise angle (in radians) from the primary axis of ground planimetric reference to the primary axis of the DEM local reference system.
 short get_data_edition()
          Returns the dem specification Data Element 28 - Data Edition: 01-99 Primarily a NIMA specific field.
 short get_data_rmse_sample_size()
          Type C Data Element 6 - Sample size on which statistics in element 5 are based, if 0, then accuracy will be assumed to be estimated rather than computed.
 short get_data_rmse()
          Type C Data Element 5 - RMSE of DEM data relative to file's datum (x, y, z) In same units as indicated by elements 8 and 9 of logical record type A.
 short get_dem_level_code()
          Returns the dem specification Data Element 3 - DEM level code: 1=DEM-1, 2=DEM-2, 3=DEM-3
 short get_elevation_pattern()
          Returns the dem specification Data Element 4 - Code defining elevation pattern (regular or random): 1=regular, 2=random is reserved for future use.
 short get_elevation_unit()
          Returns the dem specification Data Element 9 - Code defining unit of measure for elevation coordinates throughout the file: 1=feet, 2=meters.
 java.lang.String get_file_name()
          Returns the dem spefication Data Element 1 - the file name.
 short get_file_rmse_sample_size()
          Type C Data Element 3 - Sample size on which statistics in data element 2 are based If 0, then accuracy will be assumed to be estimated rather than computed.
 short get_file_rmse()
          Type C Data Element 2 - RMSE of file's datum relative to absolute datum (x, y, z) In same units as indicated by elements 8 and 9 of logical record type A.
 double[][] get_ground_coordinates()
          Returns the dem specification Data Element 11 (a 4x2 array) - A 4,2 array containing the ground coordinates of the four corners for the DEM.
 short get_horizontal_datum()
          Returns the dem specification Data Element 27 - Horizontal datum:
1=North American Datum 1927 (NAD 27)
2=World Geodetic System 1972 (WGS 72)
3=WGS 84
4=NAD 83
5=Old Hawaii Datum
6=Puerto Rico Datum
7=NAD 83 Provisional
(shifts in horizontal coordinates are computed, but old DEM nodes are not resampled)
 char get_inspection_flag()
          Returns the dem specification Data Element 23 - Inspection revision flag, "I" or "R"
 short get_largest_interval()
          Returns the dem specification Data Element 17 - Largest primary contour interval.
 double get_max_elevation()
          Convienence method for Data Element 12 (which is a 2 element array), returing the maximum elevation in a dem file.
 java.lang.String get_mc_origin()
          Returns the dem specification Data Element 2 - MC origin code, Mapping Center origin Code.
 double[] get_min_and_max_values()
          Returns the dem specification Data Element 12 (a 2 element array) - A two-element array containing minimum and maximum elevations for the DEM.
 double get_min_elevation()
          Convienence method for Data Element 12 (which is a 2 element array), returing the minimum elevation in a dem file.
 short get_percent_void()
          Returns the dem specification Data Element 29 - Percent Void: If element 25 indicates a void, this field (right justified) contains the percentage of nodes in the file set to void (-32,767).
 short get_planimetric_system()
          Returns the dem specification Data Element 5 - Code defining ground planimetric reference system: 0=Geographic, 1=UTM, 2=State plane.
 short get_planimetric_unit()
          Returns the dem specification Data Element 8 - Code defining unit of measure for ground planimetric units throughout the file: 0=radians, 1=feet, 2=meters, 3=arc-seconds Normally set to code 2 for 7.5-minute DEM's.
 short get_planimetric_zone()
          Returns the dem specification Data Element 6 - Code defining zone in ground planimetric reference system 163-168 Codes for State plane and UTM coor- dinate zones are given in appendixes D and E for 7.5-minute DEM's.
 short get_polygon_sides()
          Returns the dem specification Data Element 10 - The number (n) of sides in the polygon which defines the coverage of the DEM file, normally 4.
 double[] get_projection_parameters()
          Returns the dem specification Data Element 7 (15 element array) - Map projectionparameters (see appendix F) of measure for ground planimetric coordinates through-out the file Definition of parameters for various projections is given in appendix F.
 int get_revision_date()
          Returns the dem specification Data Element 22 - Data inspection revision date, YYMM two-digit year and two-digit month.
 short[] get_rows_and_columns()
          Returns the dem specification Data Element 16 - A two-element array containing the number of rows and columns (m,n) of profiles in the DEM When the row value m is set to 1 the n value describes the number of columns in the DEM file.
 short get_smallest_primary()
          Returns the dem specification Data Element 19 - Smallest primary.
 short get_source_date()
          Returns the dem specification Data Element 21 - Data source date YYMM two-digit year and two-digit month.
 double get_spacial_rez_x()
          convenience method for element 15 - returns spacial resolution x.
 double get_spacial_rez_y()
          convenience method for element 15 - returns spacial resolution y.
 double get_spacial_rez_z()
          convenience method for element 15 - returns spacial resolution z.
 short get_stats_available()
          Type C Data Element 1 - Returns the code indicating availability of statistics in data element 2: 1=available, 0=unavailable
 short get_suspect_and_void_flag()
          Returns the dem specification Data Element 25 - Suspect and void area flag: 0=none, 1=suspect areas, 2=void areas, 3=suspect and void areas
 short get_validation_flag()
          Returns the dem specification Data Element 24 - Data validation flag:
0= No validation performed.
1=TESDEM (record C added) no qualitative test (no DEM Edit System [DES] review).
2=Water body edit and TESDEM run.
3=DES (includes water edit) no qualitative test (no TESDEM).
4=DES with record C added, qualita tive and quantitative tests for level 1 DEM.
5=DES and TESDEM qualitative and quantitative tests for levels 2 and 3 DEM's.
 short get_vertical_datum()
          Returns the dem specification Data Element 26 - Vertical datum:
1=local mean sea level
2=National Geodetic Vertical Datum 1929 (NGVD 29)
3=North American Vertical Datum 1988 (NAVD 88)
 double[] get_xyz_resolution()
          Returns the dem specification Data Element 15 (a 3 element array) - A three-element array of DEM spatial resolution for x, y, z.
 boolean getAvailability()
          Type C Data Element 4 - availability of statistics in data element 5..
 java.lang.String getInputFile()
          Returns the name of the input file
 boolean getStatsAvailable()
          Type C Data Element 1 - Returns the availability of statistics in data element 2:
 TypeB getTypeB(int index)
          Returns the TypeB profile indexed by num.
 short maxElevationsForAllProfiles()
          This method represents data not contained in the DEM format explicitly, but that is calculated and which is important to imaging applications.
 java.lang.String toString()
          overrides java.lang.Object.toString()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dem

public Dem(java.lang.String inputfile)
Constructs a DEM from an input file specified in String inputfile

Parameters:
inputfile - String containing path to the DEM input file

Dem

public Dem(java.io.File file)
Constructs a DEM from an input file specified in java.io.File file

Parameters:
file - java.io.File

Dem

public Dem(java.net.URL url)
Constructs a DEM from a java.net.URL

Parameters:
url - java.net.URL for a dem
Since:
1.0.3
See Also:
URL
Method Detail

getInputFile

public java.lang.String getInputFile()
Returns the name of the input file

Returns:
the input file name

get_file_name

public java.lang.String get_file_name()
Returns the dem spefication Data Element 1 - the file name.

Returns:
the dem spefication Data Element 1

get_mc_origin

public java.lang.String get_mc_origin()
Returns the dem specification Data Element 2 - MC origin code, Mapping Center origin Code. Valid codes are EMC, WMC, MCMC, RMMC, FS, GPM2.

Returns:
Data Element 2 - MC origin code

get_dem_level_code

public short get_dem_level_code()
Returns the dem specification Data Element 3 - DEM level code: 1=DEM-1, 2=DEM-2, 3=DEM-3

Returns:
Data Element 3 - DEM level code

get_elevation_pattern

public short get_elevation_pattern()
Returns the dem specification Data Element 4 - Code defining elevation pattern (regular or random): 1=regular, 2=random is reserved for future use.

Returns:
Data Element 4 - Code defining elevation pattern

get_planimetric_system

public short get_planimetric_system()
Returns the dem specification Data Element 5 - Code defining ground planimetric reference system: 0=Geographic, 1=UTM, 2=State plane. (For codes 3-20, see appendix F, USGS DEM Data Users Guide Code 0 represents the geographic (latitude/longitude) system for 30-minute, 1-degree and Alaska DEM's. Code 1 represents the current use of the UTM coordinate system for 7.5-minute DEM's.

Returns:
Data Element 5 - Code defining ground planimetric reference system

get_planimetric_zone

public short get_planimetric_zone()
Returns the dem specification Data Element 6 - Code defining zone in ground planimetric reference system 163-168 Codes for State plane and UTM coor- dinate zones are given in appendixes D and E for 7.5-minute DEM's. Code is set to zero if element 5 is also set to zero defining data as geographic.

Returns:
Data Element 6 - Code defining zone in ground planimetric reference system

get_projection_parameters

public double[] get_projection_parameters()
Returns the dem specification Data Element 7 (15 element array) - Map projectionparameters (see appendix F) of measure for ground planimetric coordinates through-out the file Definition of parameters for various projections is given in appendix F. All 15 fields of this element are set to zero and should be ignored when geographic, UTM, or State plane coordinates are coded in data element 5.

Returns:
Data Element 7 - Map projectionparameters

get_planimetric_unit

public short get_planimetric_unit()
Returns the dem specification Data Element 8 - Code defining unit of measure for ground planimetric units throughout the file: 0=radians, 1=feet, 2=meters, 3=arc-seconds Normally set to code 2 for 7.5-minute DEM's. Always set to code 3 for 30-minute, 1-degree, and Alaska DEM's.

Returns:
Data Element 8 - Code defining unit of measure for ground planimetric units

get_elevation_unit

public short get_elevation_unit()
Returns the dem specification Data Element 9 - Code defining unit of measure for elevation coordinates throughout the file: 1=feet, 2=meters. Normally code 2, meters, for 7.5-minute, 30-minute, 1-degree, and Alaska DEM's.

Returns:
Data Element 9 - Code defining unit of measure for elevation coordinates throughout the file

get_polygon_sides

public short get_polygon_sides()
Returns the dem specification Data Element 10 - The number (n) of sides in the polygon which defines the coverage of the DEM file, normally 4.

Returns:
Data Element 10 - The number (n) of sides in the polygon defining the dem area

get_ground_coordinates

public double[][] get_ground_coordinates()
Returns the dem specification Data Element 11 (a 4x2 array) - A 4,2 array containing the ground coordinates of the four corners for the DEM. The coordinates of the quadrangle corners are ordered in a clockwise direction beginning with the southwest corner. The array is stored row-wise as pairs of eastings and northings.

Returns:
Data Element 11 - the ground coordinates of the four corners for the DEM

get_min_and_max_values

public double[] get_min_and_max_values()
Returns the dem specification Data Element 12 (a 2 element array) - A two-element array containing minimum and maximum elevations for the DEM. The values are in the unit of measure given by data element 9 in this record.

Returns:
Data Element 12 - minimum and maximum elevations for the DEM

get_min_elevation

public double get_min_elevation()
Convienence method for Data Element 12 (which is a 2 element array), returing the minimum elevation in a dem file. The values are in the unit of measure given by data element 9 in this record.

Returns:
Data Element 12 - - minimum elevation for the DEM

get_max_elevation

public double get_max_elevation()
Convienence method for Data Element 12 (which is a 2 element array), returing the maximum elevation in a dem file. The values are in the unit of measure given by data element 9 in this record.

Returns:
Data Element 12 - - maximum elevation for the DEM

get_counter_angle

public double get_counter_angle()
Returns the dem specification Data Element 13 - Counterclockwise angle (in radians) from the primary axis of ground planimetric reference to the primary axis of the DEM local reference system. Set to zero to align cordinate system specified in element 5.

Returns:
Data Element 13 - Counterclockwise angle

get_accuracy_code

public short get_accuracy_code()
Returns the dem specification Data Element 14 - Accuracy code for elevations: 0=unknown accuracy, 1=accuracy information is given in logical record type C.

Returns:
Data Element 14 - Accuracy code

get_xyz_resolution

public double[] get_xyz_resolution()
Returns the dem specification Data Element 15 (a 3 element array) - A three-element array of DEM spatial resolution for x, y, z. Units of measure are consistent with those indicated by data elements 8 and 9 in this record. These elements are usually set to:
30, 30, 1 for 7.5-minute DEM's
2, 2, 1 for 30-minute DEM's
3, 3, 1 for 1-degree DEM's
2, 1, 1 for high resolution DEM's in Alaska
3, 2, 1 for low resolution DEM's in Alaska
7.5-minute DEM'S will eventually be converted to geographics, i.e., 1,1,1.

Returns:
Data Element 15 - xyz spatial resolution

get_spacial_rez_x

public double get_spacial_rez_x()
convenience method for element 15 - returns spacial resolution x.

Returns:
element 15 - spacial resolution x

get_spacial_rez_y

public double get_spacial_rez_y()
convenience method for element 15 - returns spacial resolution y.

Returns:
element 15 - spacial resolution y

get_spacial_rez_z

public double get_spacial_rez_z()
convenience method for element 15 - returns spacial resolution z.

Returns:
element 15 - spacial resolution z

get_rows_and_columns

public short[] get_rows_and_columns()
Returns the dem specification Data Element 16 - A two-element array containing the number of rows and columns (m,n) of profiles in the DEM When the row value m is set to 1 the n value describes the number of columns in the DEM file. Raw GPM data files are set to m=16, n=16.

Returns:
Data Element 16 - number of rows and columns (m,n)

get_column_count

public short get_column_count()
Convenience method for Data Element 16 the number of columns in the file is the same as the number of B records

Returns:
Data Element 16 - number of columns

get_largest_interval

public short get_largest_interval()
Returns the dem specification Data Element 17 - Largest primary contour interval. Present only if two or more primary intervals exist.

Returns:
Data Element 17 - Largest primary contour interval

get_contour_interval_l

public short get_contour_interval_l()
Returns the dem specification Data Element 18 - Source contour interval units. Corresponds to the units of the map largest primary contour interval. 0=N.A., 1=feet, 2=meters.

Returns:
Data Element 18 - Source contour interval units.

get_smallest_primary

public short get_smallest_primary()
Returns the dem specification Data Element 19 - Smallest primary. Smallest or only primary contour interval

Returns:
Data Element 19 - Smallest primary contour interval

get_contour_interval_s

public short get_contour_interval_s()
Returns the dem specification Data Element 20 - Source contour interval units Corresponds to the units of the map smallest primary contour interval. 1=feet, 2=meters.

Returns:
Data Element 20 - source contour interval unit

get_source_date

public short get_source_date()
Returns the dem specification Data Element 21 - Data source date YYMM two-digit year and two-digit month. MM = 00 for source having year only.

Returns:
Data Element 21 - source date

get_revision_date

public int get_revision_date()
Returns the dem specification Data Element 22 - Data inspection revision date, YYMM two-digit year and two-digit month.

Returns:
Data Element 22 - Data inspection revision date

get_inspection_flag

public char get_inspection_flag()
Returns the dem specification Data Element 23 - Inspection revision flag, "I" or "R"

Returns:
Data Element 23 - Inspection revision flag

get_validation_flag

public short get_validation_flag()
Returns the dem specification Data Element 24 - Data validation flag:
0= No validation performed.
1=TESDEM (record C added) no qualitative test (no DEM Edit System [DES] review).
2=Water body edit and TESDEM run.
3=DES (includes water edit) no qualitative test (no TESDEM).
4=DES with record C added, qualita tive and quantitative tests for level 1 DEM.
5=DES and TESDEM qualitative and quantitative tests for levels 2 and 3 DEM's.

Returns:
Data Element 24 - Data validation flag

get_suspect_and_void_flag

public short get_suspect_and_void_flag()
Returns the dem specification Data Element 25 - Suspect and void area flag: 0=none, 1=suspect areas, 2=void areas, 3=suspect and void areas

Returns:
Data Element 25 - Suspect and void area flag

get_vertical_datum

public short get_vertical_datum()
Returns the dem specification Data Element 26 - Vertical datum:
1=local mean sea level
2=National Geodetic Vertical Datum 1929 (NGVD 29)
3=North American Vertical Datum 1988 (NAVD 88)

Returns:
Data Element 26 - vertical datum

get_horizontal_datum

public short get_horizontal_datum()
Returns the dem specification Data Element 27 - Horizontal datum:
1=North American Datum 1927 (NAD 27)
2=World Geodetic System 1972 (WGS 72)
3=WGS 84
4=NAD 83
5=Old Hawaii Datum
6=Puerto Rico Datum
7=NAD 83 Provisional
(shifts in horizontal coordinates are computed, but old DEM nodes are not resampled)

Returns:
Data Element 27 - Horizontal datum

get_data_edition

public short get_data_edition()
Returns the dem specification Data Element 28 - Data Edition: 01-99 Primarily a NIMA specific field.

Returns:
Data Element 28 - Data Edition:

get_percent_void

public short get_percent_void()
Returns the dem specification Data Element 29 - Percent Void: If element 25 indicates a void, this field (right justified) contains the percentage of nodes in the file set to void (-32,767).

Returns:
Data Element 29 - Percent Void

maxElevationsForAllProfiles

public short maxElevationsForAllProfiles()
This method represents data not contained in the DEM format explicitly, but that is calculated and which is important to imaging applications. It is the size of the largest TypeB profile, which could be the height of of an image depicting the DEM, for example.

Returns:
the maxium size for any profile (Type B record)
See Also:
TypeB

getTypeB

public TypeB getTypeB(int index)
Returns the TypeB profile indexed by num. Be sure to check typeA.get_columns(), (the number of profiles in the dem) or you will go out of bounds.

Parameters:
index - the index of the desired profile
Returns:
the profile represented by the index
See Also:
TypeB

get_stats_available

public short get_stats_available()
Type C Data Element 1 - Returns the code indicating availability of statistics in data element 2: 1=available, 0=unavailable

Returns:
Type C Data Element 1: availability of statistics for Data element 2

getStatsAvailable

public boolean getStatsAvailable()
Type C Data Element 1 - Returns the availability of statistics in data element 2:

Returns:
true if statistics are available for Data Element 2

get_file_rmse

public short get_file_rmse()
Type C Data Element 2 - RMSE of file's datum relative to absolute datum (x, y, z) In same units as indicated by elements 8 and 9 of logical record type A.

Returns:
Type C Data Element 2 - RMSE of file's datum relative to absolute datum
See Also:
TypeA.get_planimetric_unit(), get_planimetric_unit(), TypeA.get_elevation_unit(), get_elevation_unit()

get_file_rmse_sample_size

public short get_file_rmse_sample_size()
Type C Data Element 3 - Sample size on which statistics in data element 2 are based If 0, then accuracy will be assumed to be estimated rather than computed.

Returns:
Data Element 3 - sample size
See Also:
get_file_rmse()

get_availability

public short get_availability()
Type C Data Element 4 - Code indicating availability of statistics in data element 5: 1=available, 0=unavailable

Returns:
Type C Data Element 4 availability of statistics for Data Element 5

getAvailability

public boolean getAvailability()
Type C Data Element 4 - availability of statistics in data element 5..

Returns:
Type C Data Element 4 availability of statistics for Data Element 5

get_data_rmse

public short get_data_rmse()
Type C Data Element 5 - RMSE of DEM data relative to file's datum (x, y, z) In same units as indicated by elements 8 and 9 of logical record type A.

Returns:
Type C Data Element 5 - RMSE of DEM data relative to file's datum
See Also:
TypeA.get_planimetric_unit(), get_planimetric_unit(), TypeA.get_elevation_unit(), get_elevation_unit()

get_data_rmse_sample_size

public short get_data_rmse_sample_size()
Type C Data Element 6 - Sample size on which statistics in element 5 are based, if 0, then accuracy will be assumed to be estimated rather than computed.

Returns:
sample size
See Also:
get_data_rmse()

toString

public java.lang.String toString()
overrides java.lang.Object.toString()

Overrides:
toString in class java.lang.Object