Finds HDF files in a directory and converts a Scientific Data Sets (SDS) in each file to an ArcGIS raster.
| Class: | HDF |
| Intended use: | Recommended for external callers |
| COM: | Exposed as the FindAndConvertToArcGISRasters method of COM class GeoEco.HDF |
| ArcGIS: | Exposed as the Find HDFs and Convert SDS To ArcGIS Rasters geoprocessing tool |
| Method type: | Classmethod |
| updatedOutputWorkspace = HDF.FindAndConvertToArcGISRasters( | inputDirectory, outputWorkspace, sdsName, xLowerLeftCorner, yLowerLeftCorner, cellSize[, nodataValue[, wildcard[, searchTree[, minSize[, maxSize[, minDateCreated[, maxDateCreated[, minDateModified[, maxDateModified[, transpose[, mirror[, flip[, swapHemispheres[, coordinateSystem[, projectedCoordinateSystem[, geographicTransformation[, resamplingTechnique[, projectedCellSize[, registrationPoint[, clippingRectangle[, mapAlgebraExpression[, buildPyramids[, outputRasterPythonExpression[, modulesToImport[, skipExisting[, overwriteExisting]]]]]]]]]]]]]]]]]]]]]]]]]]) |
| Python type: | unicode |
| Minimum length: | 1 |
| Maximum length: | 255 |
| Must exist: | Yes |
Directory to search.
| Python type: | unicode |
| Minimum length: | 1 |
| Maximum length: | 255 |
| Must exist: | No |
Workspace to receive the ArcGIS rasters.
| Python type: | unicode |
| Minimum length: | 1 |
Name of a Scientific Data Set (SDS) in the HDF file.
If you do not know the name of the SDS, provide your best guess. If an SDS does not exist with that name, a ValueError will be raised. The error message will list the names of all SDSes present in the input file. Select one of these names try again.
You can also use the Extract HDF Header tool to dump the HDF header to a text file. In this file, each SDS will be called a "variable". You can find their names by searching the file for "Variable Name =". For example, the excerpt below from MODIS SST data lists two variables, l3m_data and l3m_qual:
Variable Name = l3m_data
Index = 0
Type= 16-bit unsigned integer
Ref. = 2
Rank = 2
Number of attributes = 4
Dim0: Name=fakeDim0
Size = 4320
Scale Type = number-type not set
Number of attributes = 0
Dim1: Name=fakeDim1
Size = 8640
Scale Type = number-type not set
Number of attributes = 0
Attr0: Name = Scaling
Type = 8-bit signed char
Count= 7
Value = linear\\000
Attr1: Name = Scaling Equation
Type = 8-bit signed char
Count= 47
Value = (Slope*l3m_data) + Intercept = Parameter
value\\000
Attr2: Name = Slope
Type = 32-bit floating point
Count= 1
Value = 0.000717
Attr3: Name = Intercept
Type = 32-bit floating point
Count= 1
Value = -2.000000
Variable Name = l3m_qual
Index = 1
Type= 8-bit unsigned integer
Ref. = 4
Rank = 2
Number of attributes = 1
Dim0: Name=fakeDim2
Size = 4320
Scale Type = number-type not set
Number of attributes = 0
Dim1: Name=fakeDim3
Size = 8640
Scale Type = number-type not set
Number of attributes = 0
Attr0: Name = valid_range
Type = 32-bit signed integer
Count= 2
Value = 0 2This tool extracts the HDF SDS to an ArcInfo ASCII Grid and converts it to a raster using the ArcGIS ASCII to Raster geoprocessing tool. That tool and the ArcGIS raster format have several limitations that constrain the kinds of SDSes that may be successfully converted to ArcGIS raster format.
SDSes that use the float or double data type must not contain "infinity" (INF) or "not a number" (NAN) values. A ValueError will be raised if these values are discovered.
The ArcGIS raster format supports the 32-bit float data type but not the 64-bit double data type. If you supply an SDS with the double data type, it will be converted to a 32-bit float raster using the ArcGIS ASCII to Raster geoprocessing tool. The tool's behavior in this situation is not documented. In ArcGIS 9.1 it appears to be:
The ArcGIS 9.1 ASCII to Raster tool also exhibits some quirks when converting integer rasters:
| Python type: | float |
X coordinate of the lower-left corner of the raster.
The coordinate is for the corner of the lower-left cell, not the center of that cell. For example, if the raster is a geographic projection of the entire Earth, the coordinate of the lower left corner would be -180.0, corresponding to a longitude of 180 degrees West.
| Python type: | float |
Y coordinate of the lower-left corner of the raster.
The coordinate is for the corner of the lower-left cell, not the center of that cell. For example, if the raster is a geographic projection of the entire Earth, the coordinate of the lower left corner would be -90.0, corresponding to a latitude of 90 degrees South.
| Python type: | float |
Size of each raster cell.
For example, if the raster is a geographic projection of the entire Earth, with 720 columns and 360 rows, it would have a cell size of 0.5, corresponding to 1/2 of a geographic degree.
The underlying data format requires the cells be square. It is not possible to specify a cell size for each dimension.
| Python type: | float or None |
| Default value: | None |
Value that indicates a cell has no data.
| Python type: | unicode |
| Default value: | u'*' |
| Minimum length: | 1 |
UNIX-style "glob" wildcard expression specifying the pathnames to find.
The glob syntax supports the following patterns:
seq is one or more characters, such as abc. You may specify character ranges using a dash. For example, a-z0-9 specifies all of the characters in the English alphabet and the decimal digits 0 through 9.
You may specify subdirectories in the glob expression. For example, the expression cruise*/sst* will find all paths beginning with sst that are contained in directories beginning with cruise.
The operating system determines whether / or \ is used as the directory separator. On Windows, both will work. On most flavors of UNIX, / must be used.
The operating system determines if matching is case sensitive. On Windows, matching is case-insensitive. On most flavors of UNIX, matching is case-sensitive.
| Python type: | bool |
| Default value: | False |
If True, subdirectories will be searched.
| Python type: | int or None |
| Default value: | None |
| Minimum value: | 0 |
Minimum size, in bytes, of files to find. If provided, only files that are this size or larger will be found.
| Python type: | int or None |
| Default value: | None |
| Minimum value: | 0 |
Maximum size, in bytes, of files to find. If provided, only files that are this size or smaller will be found.
| Python type: | datetime.datetime or None |
| Default value: | None |
Minimum creation date, in the local time zone, of the files to find, as reported by the operating system. If provided, only files that were created on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.
| Python type: | datetime.datetime or None |
| Default value: | None |
Maximum creation date, in the local time zone, of the files to find, as reported by the operating system. If provided, only files that were created on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.
| Python type: | datetime.datetime or None |
| Default value: | None |
Minimum modification date, in the local time zone, of the files to find, as reported by the operating system. If provided, only files that were modified on or after this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.
| Python type: | datetime.datetime or None |
| Default value: | None |
Maximum modification date, in the local time zone, of the files to find, as reported by the operating system. If provided, only files that were modified on or before this date will be found. You may provide a date with or without a time. If you do not provide a time, it is assumed to be midnight.
| Python type: | bool |
| Default value: | False |
If True, the image will be transposed (flipped about the diagonal axis) prior to conversion. Use this option to fix an image that has the east/west axis going up and down instead of left and right.
| Python type: | bool |
| Default value: | False |
If True, the image will be flipped about the vertical axis prior to conversion. Use this option to fix an image that is the "mirror image" of what it is supposed to be.
| Python type: | bool |
| Default value: | False |
If True, the image will be flipped about the horizontal axis prior to conversion. Use this option to fix an image that is upside-down.
| Python type: | bool |
| Default value: | False |
If True, the east and west hemispheres of the image will be swapped. Use this option to change the orientation of a global image from a 0 to 360 orientation centered on the Pacific ocean to a -180 to +180 orientation centered on the Atlantic ocean, or visa versa.
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
Coordinate system to define for the raster.
If a value is not provided, the coordinate system of the raster will remain undefined.
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
New coordinate system to project the raster to.
The raster may only be projected to a new coordinate system if the original projection is defined. An error will be raised if you specify a new coordinate system without defining the original coordinate system.
The ArcGIS Project Raster tool is used to perform the projection. The documentation for that tool recommends that you also specify a cell size for the new coordinate system.
I have noticed that for certain coordinate systems the ArcGIS 9.2 Project Raster tool seems to clip the projected raster to an arbitrary extent that is too small. For example, when projecting a global MODIS Aqua 4 km chlorophyll image in geographic coordinates to Lambert_Azimuthal_Equal_Area with central meridian of -60 and latitude of origin of -63, the resulting image is clipped to show only one-quarter of the planet. This problem does not occur when Project Raster is invoked interactively from the ArcGIS user interface; it only occurs when the tool is invoked programmatically (the ProjectRaster_management method of the geoprocessor). Thus you may not see it when you use Project Raster yourself but it may happen when you use MGET tools that invoke Project Raster as part of their geoprocessing operations.
If you encounter this problem, you can work around it like this:
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
A transformation method used to convert between the original coordinate system and the new coordinate system.
This parameter is a new option introduced by ArcGIS 9.2. You must have ArcGIS 9.2 to use this parameter.
This parameter is only needed when you specify that the raster should be projected to a new coordinate system and that new system uses a different datum than the original coordinate system, or there is some other difference between the two coordinate systems that requires a transformation. To determine if a transformation is needed, I recommend the following procedure:
| Python type: | unicode or None |
| Default value: | None |
| Allowed values: | u'NEAREST', u'BILINEAR', u'CUBIC' |
The resampling algorithm to be used to project the original raster to a new coordinate system. The ArcGIS Project Raster tool is used to perform the projection and accepts the following values:
You must specify one of these algorithms to project to a new coordinate system. An error will be raised if you specify a new coordinate system without selecting an algorithm.
| Python type: | float or None |
| Default value: | None |
The cell size of the projected coordinate system. Although this parameter is optional, to receive the best results, the ArcGIS documentation recommends you always specify it when projecting to a new coordinate system.
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
| Must match regular expression: | ([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?) |
The x and y coordinates (in the output space) used for pixel alignment.
This parameter is a new option introduced by ArcGIS 9.2. You must have ArcGIS 9.2 to use this parameter. It is ignored if you do not specify that the raster should be projected to a new coordinate system.
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
| Must match regular expression: | ([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)\s+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?) |
Rectangle to which the raster should be clipped.
If a projected coordinate system was specified, the clipping is performed after the projection and the rectangle's coordinates should be specified in the new coordinate system. If no projected coordinate system was specified, the coordinates should be specified in the original coordinate system.
The ArcGIS Clip tool is used to perfom the clip. The clipping rectangle must be passed to this tool as a string of four numbers separated by spaces. The ArcGIS user interface automatically formats the string properly; when invoking this tool from the ArcGIS UI, you need not worry about the format. But when invoking it programmatically, take care to provide a properly-formatted string. The numbers are ordered LEFT, BOTTOM, RIGHT, TOP. For example, if the raster is in a geographic coordinate system, it may be clipped to 10 W, 15 S, 20 E, and 25 N with the string:
10 15 20 25
Integers or decimal numbers may be provided.
| Python type: | unicode or None |
| Default value: | None |
| Minimum length: | 1 |
| Maximum length: | 4000 |
Map algebra expression to execute on the raster.
WARNING: The ArcGIS Geoprocessing Model Builder may randomly and silently delete the value of this parameter. This is a bug in ArcGIS. Before running a model that you have saved, open this tool and validate that the parameter value still exists.
The expression is executed after the converted raster is projected and clipped (if those options are specified). Use the case-sensitive string inputRaster to represent the raster that you now want to perform map algebra upon. For example, to convert the raster to an integer raster and add 1 to all of the cells, use this expression:
int(inputRaster) + 1
The string inputRaster is case-sensitive. Prior to executing the map algebra expression, the string is replaced with the path to a temporary raster that represents the raster being generated. The final expression must be less than 4000 characters long or ArcGIS will report an error.
The ArcGIS Single Output Map Algebra tool is used to execute the map algebra expression. You must have a license for the ArcGIS Spatial Analyst extension in order to perform map algebra.
Map algebra syntax can be very picky. Here are some tips that will help you succeed with this tool:
| Python type: | bool |
| Default value: | False |
If True, pyramids will be built for the raster, which will improve its display speed in the ArcGIS user interface.
| Python type: | unicode or None |
| Default value: | u'os.path.join(outputWorkspace, os.path.dirname(inputFile[len(directoryToSearch)+1:]), os.path.basename(inputFile).split(u'.')[0][:13])' |
| Minimum length: | 1 |
Python expression used to calculate the absolute path of an output raster. The expression may be any Python statement appropriate for passing to the eval function and must return a Unicode string. The expression may reference the following variables:
The default expression:
os.path.join(outputWorkspace, os.path.dirname(inputFile[len(directoryToSearch)+1:]), os.path.basename(inputFile).split(u'.')[0][:13])
stores the raster in the output workspace at the same relative location that the input file appears in the directory to search. The output raster name consists of no more than the first 13 characters of the input file name.
For more information on Python syntax, please see the Python documentation.
| Python type: | list of unicode, or None |
| Default value: | [u'os.path'] |
| Minimum length: | 0 |
Python modules to import prior to evaluating the expression. If you need to access Python functions or classes that are provided by a module rather than being built-in to the interpreter, list the module here. For example, to be able to use the datetime class in your expression, list the datetime module here. In your expression, you must refer to the class using its fully-qualified name, datetime.datetime.
| Python type: | bool |
| Default value: | False |
If True, processing will be skipped for rasters that already exist.
| Python type: | bool |
| Default value: | False |
If True and skipExisting is False, existing rasters will be overwritten.
| Python type: | unicode |
| Minimum length: | 1 |
| Maximum length: | 255 |
| Must exist: | No |
Workspace to receive the ArcGIS rasters.