Gp.Times_sa(InRaster, 0. we used the addition and the multiplication operations of Raster Calculator, and we did in two separate lines as follows: We recognize that arcpy.gp.RasterCalculator_sa does not exist and does not work in python. I have solved the problem by helping of one of my friend. # If an error occurred while running a tool, then print the messages. # Check out Spatial Analyst extension licenseĪrcpy.gp.RasterCalculator_sa("0.5913 *" + InRaster + " + 0.3896", OutRaster) Similar to other geoprocessing tools available in ArcGIS Desktop, REPTool can be run from a dialog window, from the ArcMap command line, or from a Python script. # Set the outputname for each output to be the same as the input. You should either save the output in a folder or remove the extension. Also, a raster cannot have a dot in its name when saving to a gdb. Out_workspace = "D:/Rc_FPAR_test/FPAR250" tif cannot be saved in a file geodatabase (. Gp.workspace = "D:/Rc_FPAR_test/FPAR1000" Gp.AddToolbox("C:/Program Files/ArcGIS/Desktop10.0/ArcToolbox/Toolboxes/Spatial Analyst Tools.tbx") Import sys, string, os, arcgisscripting, math, arcpy Parameters are not valid.ĮRROR 000989: Python syntax error: Parsing error : invalid syntax (line 1) however i got the following error:ĮxecuteError: Failed to execute. # Check out the ArcGIS Spatial Analyst extension licenseĪ="C:/Users/Vaio/FULLPATHNAME/Monthly_Original.I want to use raster calculator with loop to consider many raters. The result from this conversion will give an indication about what the default output of the zonal operation will be. The '.save' cannot be capitalized ( AttributeError: 'Raster' object has no attribute 'Save')ĮDIT: Now that I finally have access to the software I was able to revise your code - you may need to modify to suit your actual data (see comments and online help): import arcpy To demonstrate this, try converting the feature dataset to a raster with the appropriate feature-to-raster conversion tool and specify the resolution to be that of the Value raster. The very last line needs to be changed from 'OutTaster' to 'OutRaster' ( NameError: name 'OutTaster' is not defined) ( RuntimeError: ERROR 010093: Output raster format UNKNOWN is unsupported.) If the capitalization is incorrect, the expression will be invalid and fail to execute because Python is case sensitive. If Extent is specified in the environment setting and the lower-left corner of the output extent does not match any cell corner of the input raster, during processing, a shift of the cell alignment of the input raster will occur to match the specified extent. The '*' characters used in the output name will cause more errors. What are the '*' in 'p_2000_*.*' supposed to mean? If you want variables then you may need a counter variable defined, or extract the original file name from the item used in the for loop with rasterlist to replace the first '*' (perhaps the second '*' could be replaced with the text for the desired output raster file extension). For specific Python issues, consult the external Python help for the version of Python you're using, or consult the Calculate Field or Calculate Value help for more information on these tools. This is the reason for the invalid syntax error: 'OutRaster=(Raster(rasterlist)/100' has two opening parentheses but only one closing parenthesisĭo not use '.Name' for assigning the output name ( AttributeError: 'Raster' object has no attribute 'Name') Note: (lower case) '.name' is Read Only 'range()' expects atleast one argument - or try something like for ' k in rasterlist:' ( TypeError: range expected at least 1 arguments, got 0) 'ListRasters(p)' needs to have the variable 'p' previously defined ( NameError: name 'p' is not defined) No indentation needed after the import statementsĬheck out the ArcGIS Spatial Analyst extension license using 'arcpy.CheckOutExtension("Spatial")' ( RuntimeError: ERROR 000824: The tool is not licensed.)Īssuming that 'arcpy.workspace="C:/Users/Vaio/./Monthly_Original.gdb"' is not the actual directory path run in the code, but merely abbreviated for posting here - you still need to state arcpy. Insert 'import arcpy' at the top of your code ( NameError: name 'arcpy' is not defined)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |