1

I have a folder with ~1200 aerial photos in both jp2 and tif format, of which I need about 380. I wrote a python script to get the names of the files I need, which works fine. But when the script copies the data, 1. it goes very slowly, 2. the file size for the jps file expands from 92k kb to 200k kb or more. It also creates ovr files an the 150K kb range. Is this normal? ArcGIS 10.0 all round. Thanks.

lst_names = arcpy.SearchCursor(raster_names, "", "", name_field, name_field)

for row in lst_names:
    arcpy.CopyRaster_management(from_folder + row.name, to_folder + row.name)
4
  • Are you converting .jp2 to .tif or an ESRI grid?
    – Aaron
    Jan 9, 2014 at 15:26
  • No, just straightforward copying. Have identical photos in both formats.
    – recurvata
    Jan 10, 2014 at 18:26
  • I assume you are specifying a file extension (e.g. .tif) in the Copy Raster tool?
    – Aaron
    Jan 10, 2014 at 18:57
  • Yes, but the problem seems to be more or less solved by using the plain copy tool. Thanks.
    – recurvata
    Jan 10, 2014 at 19:02

2 Answers 2

2

If you simply want to copy the rasters without changing format, compression, or building overviews then use standard filesystem copy (in the shutil module) instead of the CopyRaster tool as i.e.

import shutil
shutil.copy(inpath, outpath)

You could also use the Copy tool

arcpy.Copy_management(inpath, outpath)

The advantage of the Copy tool is that it will also copy all related files, i.e if you are copying someraster.tif then someraster.tfw and someraster.aux.xml etc... will also get copied.

1
  • Thanks. The Copy tool seemed to do the trick. Files copied in ~30 seconds vs. 3 minutes for CopyRaster. I didn't try the shutil because I'm happy with the results, but may try it for comparison. All the answers were helpful.
    – recurvata
    Jan 10, 2014 at 18:25
1

You'll need to configure your environmental variables for rasters. By default, its going to build pyramids and change the compression level of the file.

You can read more about them here.

Pyramids are reduced-resolution representations of your dataset. They can speed up display of raster datasets by retrieving only the data that is necessary at a specified resolution. By default, pyramids are created for raster datasets.

For speed, you may want to look into where you are storing your data (is it going over a network, is it on disk?).

2
  • Thanks. The original data is on an external hard drive with a USB connection to the desktop, copying into a folder on my local drive. Eventually will move it to the server, but for now just trying to get it to work. I'll check out your link, appreciate it.
    – recurvata
    Jan 9, 2014 at 15:03
  • 1
    If you're going to be doing any heavy raster processing, it's probably (depending on your network speed) faster to do it on the USB drive. Better if you're using a USB 3.0 connection.
    – DPierce
    Jan 9, 2014 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.