Raster to Float (Conversion)
Summary
Converts a raster dataset to a file of binary floating-point values representing raster data.
Usage
-
The input raster dataset can be any valid raster dataset.
-
Two outputs are created: an IEEE floating-point format 32-bit signed binary file with a .flt extension and an ASCII header file with a .hdr extension. Both will use the same output floating-point raster file name.
-
The ASCII file consists of header information containing a set of keywords.
The format of the file in general is:
NCOLS xxx NROWS xxx XLLCORNER xxx YLLCORNER xxx CELLSIZE xxx NODATA_VALUE xxx BYTEORDER <MSBFIRST | LSBFIRST>
The definitions of the keywords are as follows:
NCOLS and NROWS are the number of columns and rows in the raster defined by the binary file.
XLLCORNER and YLLCORNER are the coordinates of the lower left corner of the lower left cell.
The use of XLLCENTER and YLLCENTER is not supported by Raster to Float.
CELLSIZE is the cell size of the raster.
NODATA_VALUE is the value that is to represent NoData cells.
BYTEORDER represents how multibyte binary numbers are stored on the system on which the binary file was generated. On Intel-based systems, the byte order is LSBFIRST (also known as Big Endian). On most other architectures (all UNIX systems except Alpha, and older Macintosh with Motorola CPUs), the byte order is MSBFIRST (also known as Little Endian).
-
The NODATA_VALUE is the value in the output file assigned to those cells in the input raster that contain NoData. This value is normally reserved for those cells whose true value is unknown.
-
By default, NoData values on the input raster will have a value of -9999 in the output float file. If you want to use another value to represent NoData, a procedure similar to the following can be applied:
- Run the ArcGIS Spatial Analyst extension IsNull tool on the original raster. The output will be a raster of binary values, where 1 corresponds to NoData on the original raster and 0 is any other value.
- Run the ArcGIS Spatial Analyst extension Con tool, specifying the IsNull result as the Input Conditional Raster, the new value to assign NoData values to as the Input True value, the original raster as the Input False raster, and a condition Expression of "value = 1".
- Convert the Con output raster to a floating-point binary file with Raster To Float
- Change the value of NODATA_VALUE in the ASCII header file to the value that NoData was converted to.
-
This tool only writes the origin as the lower left corner of the lower left cell. The Float to Raster tool also supports the origin as the center of the lower left cell.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The input raster dataset. The raster can be integer or floating-point type. | Raster Layer |
out_float_file |
The output floating-point raster file. The file name must have a .flt extension. | File |
Code Sample
Converts a raster dataset to a file of binary floating-point values representing raster data.
import arcpy
from arcpy import env
env.workspace = "C:/data"
inRaster = "elevation"
outFloat = "c:/output/elevation.flt"
arcpy.RasterToFloat_conversion("elevation", "c:/output/elevation.flt")
Converts a raster dataset to a file of binary floating-point values representing raster data.
# Name: RasterToFloat_Ex_02.py
# Description: Converts a raster dataset to a file of binary floating-point
# values representing raster data.
# Requirements: None
# Import system modules
import arcpy
from arcpy import env
# Set environment settings
env.workspace = "C:/data"
# Set local variables
inRaster = "elevation"
outFloat = "c:/output/elevation.flt"
# Execute RasterToFloat
arcpy.RasterToFloat_conversion(inRaster, outFloat)