Copy Raster (Data Management)
Summary
Makes a copy of a raster dataset, loads raster datasets into a raster catalog, or converts a mosaic dataset into a raster dataset.
Usage
-
You can save your output to BIL, BIP, BMP, BSQ, DAT, Esri Grid, GIF, IMG, JPEG, JPEG 2000, PNG, TIFF, or any geodatabase raster dataset.
-
When storing a raster dataset in a geodatabase, no file extension should be added to the name of the raster dataset. When storing the raster dataset in a file format, you need to specify the file extension:
- .bil for Esri BIL
- .bip for Esri BIP
- .bmp for BMP
- .bsq for Esri BSQ
- .dat for ENVI DAT
- .gif for GIF
- .img for ERDAS IMAGINE
- .jpg for JPEG
- .jp2 for JPEG 2000
- .png for PNG
- .tif for TIFF
- no extension for Esri Grid
This tool can be used to scale your pixel type from one bit depth to another. When you scale your pixel depth, your raster will display the same, but the values will be scaled to the new bit depth that was specified.
-
The output of this tool is always a raster dataset, even if the raster datasets are being loaded into a raster catalog. This tool will accept a mosaic dataset as the input, but the output will still be a raster dataset—the contents of the mosaic dataset will be mosaicked to create a raster dataset.
-
This tool can be used to load raster datasets into a raster catalog. If you want to load raster datasets into a raster catalog, you will need to type out the full path of the raster catalog as the output location or drag the raster catalog into the output text box.
-
If this tool is used to load raster datasets into a raster catalog, then the Calculate Default Spatial Grid Index tool will need to be run after the loading is completed.
-
For file-based rasters and personal geodatabase rasters, the Ignore Background Value must be set to the same value as NoData in order for the background value to be ignored. File geodatabase rasters and ArcSDE rasters will work without this extra step.
-
When storing your raster dataset to a JPEG file, a JPEG 2000 file, or a geodatabase, you can specify a Compression type and Compression Quality within the Environment Settings.
-
The GIF format only supports single-band raster datasets.
-
The pixel-type parameter determines the bit depth of the output raster dataset. There is rescaling of the raster values when a different pixel type is chosen. If the pixel type is demoted (lowered), the raster values outside the valid range for that pixel depth will be truncated and lost. To learn about the bit-depth capacity for supported export formats, see Supported raster dataset file formats.
Syntax
Parameter | Explanation | Data Type |
in_raster |
The name and location of the raster dataset to be copied. | Mosaic Dataset; Mosaic Layer; Raster Dataset; Raster Layer |
out_rasterdataset |
The name and location of the raster dataset to be created. When storing the raster dataset in a file format, you need to specify the file extension:
When storing a raster dataset in a geodatabase, no file extension should be added to the name of the raster dataset. When storing your raster dataset to a JPEG file, a JPEG 2000 file, a TIFF file, or a geodatabase, you can specify a compression type and compression quality. | Raster Dataset; Raster Catalog |
config_keyword (Optional) |
Specifies the storage parameters (configuration) for a file geodatabase and an ArcSDE geodatabase. Personal geodatabases do not use configuration keywords. ArcSDE configuration keywords are set up by your database administrator. | String |
background_value (Optional) |
Use this option to remove the unwanted values created around the raster data. The value specified will be distinguished from other valuable data in the raster dataset. For example, a value of zero along the raster dataset's borders will be distinguished from zero values within the raster dataset. The pixel value specified will be set to NoData in the output raster dataset. For file-based rasters and personal geodatabase rasters, the Ignore Background Value must be set to the same value as NoData in order for the background value to be ignored. ArcSDE and file geodatabase rasters will work without this extra step. | Double |
nodata_value (Optional) |
All the pixels with the specified value will be set to NoData in the output raster dataset. | String |
onebit_to_eightbit (Optional) |
Choose whether the input 1-bit raster dataset will be converted to an 8-bit raster dataset. In this conversion the value 1 in the input raster dataset will be changed to 255 in the output raster dataset. This is useful when importing a 1-bit raster dataset to ArcSDE. One-bit raster datasets have 8-bit pyramid layers when stored in a file system, but in ArcSDE, 1-bit raster datasets can only have 1-bit pyramid layers, which makes the display unpleasant. By converting the data to 8 bit in ArcSDE, the pyramid layers are built as 8 bit instead of 1 bit, resulting in a proper raster dataset in the display.
| Boolean |
colormap_to_RGB (Optional) |
If the input raster dataset has a color map, the output raster dataset can be converted to a three-band output raster dataset. This is useful when mosaicking rasters with different color maps.
| Boolean |
pixel_type (Optional) |
Determines the bit depth of the output raster dataset. If left unspecified, the output bit depth will be the same as the input. There will be no rescaling of the raster values when a different pixel type is chosen. If the pixel type is demoted (lowered), the raster values outside the valid range for that pixel depth will be truncated and lost.
| String |
scale_pixel_value (Optional) | When the output is a different pixel type than the input (such as 16-bit to 8-bit) you can choose to have the values scaled to fit into the new range; otherwise, the values that do not fit into the new pixel range will be discarded. If scaling up, such as 8-bit to 16-bit, the minimum and maximum of the 8-bit values will be scaled to the minimum and maximum in the 16-bit range. If scaling down, such as 16-bit to 8-bit, the minimum and maximum of the 16-bit values will be scaled to the minimum and maximum in the 8-bit range.
| Boolean |
RGB_to_Colormap (Optional) | You can convert an 8-bit, 3-band (RGB) raster dataset, to a single-band raster dataset with a color map. This operation will suppress color noise that is often found in scanned images by examining the statistics for the raster dataset and classifying the values into 255 quantiles. This is ideal for screen captures, scanned maps, or scanned documents. This is not recommended for satellite or aerial imagery or thematic raster data.
| Boolean |
Code Sample
This is a Python sample for the CopyRaster tool.
import arcpy
arcpy.CopyRaster_management("c:/data/background.tif",
"c:/fdgb/CpRaster.gdb/fgdbRD","DEFAULTS",
"0","9","","","8_BIT_UNSIGNED")
This is a Python script sample for the CopyRaster tool.
##====================================
##Copy Raster
##Usage: CopyRaster_management in_raster out_rasterdataset {config_keyword} {background_value} {nodata_value} {NONE | OneBitTo8Bit}
## {NONE | ColormapToRGB} {1_BIT | 2_BIT | 4_BIT | 8_BIT_UNSIGNED | 8_BIT_SIGNED | 16_BIT_UNSIGNED
## | 16_BIT_SIGNED | 32_BIT_UNSIGNED | 32_BIT_SIGNED | 32_BIT_FLOAT | 64_BIT}
try:
import arcpy
arcpy.env.workspace = r"C:\PrjWorkspace"
##Copy File RasterDataset to GDB Dataset with Background and Nodata setting
arcpy.CopyRaster_management("background.tif","CpRaster.gdb\\background","DEFAULTS","0","9","","","8_BIT_UNSIGNED")
##Copy 1 BIT
arcpy.CopyRaster_management("1bit.tif","SDE94.sde\\bit8","DEFAULTS","","","OneBitTo8Bit","","")
except:
print "Copy Raster example failed."
print arcpy.GetMessages()