+ Reply to Thread
Results 1 to 8 of 8

Thread: Runscript Error - line 312???

  1. #1
    Mike Bly
    Join Date
    Nov 2011
    Posts
    45
    Points
    1
    Answers Provided
    1


    0

    Default Runscript Error - line 312???

    Anyone know why I get this error in my traceback: The first and last errors - I cannot find any documentation on.

    Any ideas would be greatly appreciated. This is a very simple script to rename a batch of raster files.

    Traceback (most recent call last):
    File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
    File "G:\Documentation\Python_Scripts\batchCopyRaster_COL.py", line 32, in <module>
    arcpy.CopyRaster_management(input,output)
    File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 6835, in CopyRaster
    raise e
    ExecuteError: Failed to execute. Parameters are not valid.

    Thanks

  2. #2
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,370
    Points
    958
    Answers Provided
    150


    0

    Default Re: Runscript Error - line 312???

    Have you checked to make sure the files and folders exist, have valid names etc?
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  3. #3
    Darren Wiens

    Join Date
    Apr 2011
    Posts
    821
    Points
    271
    Answers Provided
    37


    0

    Default Re: Runscript Error - line 312???

    Sorry to say it, but I'd guess the parameters are not valid (either "input" or "output"), but you'd have to post the code for anyone to figure it out.

  4. #4
    Mike Bly
    Join Date
    Nov 2011
    Posts
    45
    Points
    1
    Answers Provided
    1


    0

    Default Re: Runscript Error - line 312???

    Quote Originally Posted by mzcoyle View Post
    Have you checked to make sure the files and folders exist, have valid names etc?
    All the files and folders look correct, and the script references the proper locations, ???

    Thanks,

    Mike

  5. #5
    Mike Bly
    Join Date
    Nov 2011
    Posts
    45
    Points
    1
    Answers Provided
    1


    0

    Default Re: Runscript Error - line 312???

    Quote Originally Posted by dkwiens View Post
    Sorry to say it, but I'd guess the parameters are not valid (either "input" or "output"), but you'd have to post the code for anyone to figure it out.
    Here is the super simple code - I must be missing something obvious - be kind I am a newbie to scripting...


    # Import system modules
    import arcpy

    #Set working directory

    arcpy.env.workspace = "G:\Imagery\Orthos_2009\Photos\TIFF"

    # Define Input and Output folder

    InFolder = "G:\Imagery\Orthos_2009\Photos\TIFF"
    OutFolder = "G:\Imagery\Orthos_2009\Photos\TIFF_Renamed"

    # Create List of Rasters in Folder

    rasterList = arcpy.ListRasters()

    # Loop Through Folder renaming rasters and save in new folder

    for raster in rasterList:
    print("Beginning Copy of " + raster)
    input = InFolder + "/" + raster
    output = OutFolder + "/nn" + raster
    #Copy Rasters
    arcpy.CopyRaster_management(input,output)
    print(" Copy of " + raster + " complete." + "\n")
    rasterList.next()

    del arcpy


    Any thoughts here, thanks for the help,

    Cheers,

    Mike

  6. #6
    Mathew Coyle

    Join Date
    Feb 2011
    Posts
    1,370
    Points
    958
    Answers Provided
    150


    0

    Default Re: Runscript Error - line 312???

    Your paths are incorrect. Valid path formats are as follows.

    Code:
    arcpy.env.workspace = r"G:\Imagery\Orthos_2009\Photos\TIFF"
    arcpy.env.workspace = "G:\\Imagery\\Orthos_2009\\Photos\\TIFF"
    arcpy.env.workspace = "G:/Imagery/Orthos_200/Photos/TIFF"
    The proper way to combine a path and file name are as follows. Both of these require importing the os module
    Code:
    input = os.path.join(InFolder,raster) # Much preferred
    input = InFolder + os.sep + raster
    Mathew Coyle, EADA10
    GIS Analyst
    Alberta-Pacific Forest Industries Inc.
    ArcGIS 10.2.1 Testing
    ArcGIS 10.1 SP1
    Windows 7 SP1 64-bit

  7. #7
    Mike Bly
    Join Date
    Nov 2011
    Posts
    45
    Points
    1
    Answers Provided
    1


    0

    Default Re: Runscript Error - line 312???

    Quote Originally Posted by mzcoyle View Post
    Have you checked to make sure the files and folders exist, have valid names etc?
    Thanks for this - got me thinking about supported file types with the Copy Raster function - I was using ECW file which are not supported. Switched over to TIFFs and the code works - kinda - just need to figure the looping. Creates first file properly and then quits - this is due to my rasterList.next() which is a 9.3 function - need to figure the 10.

    Cheers,

    mike

  8. #8
    Mike Bly
    Join Date
    Nov 2011
    Posts
    45
    Points
    1
    Answers Provided
    1


    0

    Default Re: Runscript Error - line 312???

    Hi,

    I managed to get the code to start working, let it run through the renaming of a few of the files - the new problem is the quality of the new raster file. There are two attachments for those who may be curious.

    I found that the pixel value remains - however the stretched value is changed upon running the script. I have found a work around outside of python, but if there any ideas as to why the stretched value would get modified, be great to hear.

    Thanks again,

    MIke
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	Before.JPG‎
Views:	23
Size:	16.0 KB
ID:	14026   Click image for larger version

Name:	After_.JPG‎
Views:	24
Size:	27.3 KB
ID:	14027  
    Last edited by mbly29; 05-03-2012 at 06:55 AM.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts