1

Edit: the error was caused by spelling .tif as .tiff`.

The script ran fine before I added InSR, the input coordinate system.

I'm getting the following error:

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid. ERROR 000445: Extension is invalid for the output raster format. Failed to execute (ProjectRaster).

Here is my code:

import arcpy, sys, os
InFolder = r"E:\ReprojectionScript"
OutFolder = r"E:\ReprojectionScript\test"
OutSR = arcpy.SpatialReference(26918) # NAD83 / UTM zone 18N
InSR = arcpy.SpatialReference(26996) # Missouri East
arcpy.env.workspace = InFolder
rasterList = arcpy.ListRasters()
for Ras in rasterList :
 inRaster = os.path.join(InFolder, Ras)
 outFileName = "{}.{}".format(os.path.splitext(Ras)[0], "tif") # Remove .sid and add .tif to Ras filename
 outRaster = os.path.join(OutFolder, outFileName) # Path and Filename of output raster (.tif)
 arcpy.ProjectRaster_management (inRaster, outRaster, OutSR, "", "", "", "", InSR) 
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 22, 2016 at 1:17
4
  • Try replacing the optional parameters "" with "#" Commented Sep 22, 2016 at 1:36
  • I tried replacing the "" with # but it returned same error. Commented Sep 22, 2016 at 2:55
  • yeah sorry, that probably didn't help. jbalk's revised answer looks good though Commented Sep 22, 2016 at 3:30
  • Did you find a solution to this already? It appears as if you posted a solution as an edit. If that is the case, please either accept the existing answer or add an answer of your own so we can consider this question resolved. Commented Jun 26, 2017 at 11:21

1 Answer 1

2

The error you receive is a result of passing a spatial reference object into a parameter that does not accept spatial reference objects.

From the tool description:

out_coor_system (Coordinate System): The coordinate system to which the input raster will be projected. The default value is set based on the Output Coordinate System environment setting.Valid values for this parameter are

  • A file with the .prj extension.

  • An existing feature class, feature dataset, raster catalog (basically anything with a coordinate system).

  • The string representation of a coordinate system. These lengthy strings can be generated by adding a coordinate system variable to ModelBuilder, setting the variable's value as desired, then exporting the model to a Python script.

To fix your code try this (updated after reading Faith_Dur's comment):

OSR = arcpy.SpatialReference(26918) # NAD83 / UTM zone 18N
ISR = arcpy.SpatialReference(26996) # Missouri East
OutSR = OSR.exportToString()
InSR = ISR.exportToString()

Or This:

OutSR = "PROJCS['NAD_1983_UTM_Zone_18N',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',500000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-75.0],PARAMETER['Scale_Factor',0.9996],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Meter',1.0]]"
InSR = "PROJCS['NAD_1983_StatePlane_Missouri_East_FIPS_2401',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',250000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-90.5],PARAMETER['Scale_Factor',0.9999333333333333],PARAMETER['Latitude_Of_Origin',35.83333333333334],UNIT['Meter',1.0]]"
answered Sep 22, 2016 at 1:47
1
  • 1
    OutSR.exportToString() will give the same outcome Commented Sep 22, 2016 at 2:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.