Try moving line 7
into the if statement.
It looks like this is being called on a non-existent .tif and will fail, causing the script to error out before reaching the if statement for this particular dataset.
for inras in inras_list[5:]:
I guess Michael Stimson is suggesting to do something like:
for x in filestoo:
# Determine the new output feature class path and name
outfc = os.path.join(outshape, x)
# run project tool
arcpy.Project_management(x, outfc, outCS)
Create a function to rotate points then use the da.UpdateCursor to update the geometry for each polygon. Code below will modify your data so backup before you try it:
import arcpy, math
fc = 'aPoly' #Change to match your data
rotatefield = 'Rotation' #Clockwise rotation in degress. Change name to match your data
#Function to rotate one input Point around ...
This is somewhat guessing since your code snippet doesn't include some of the details, however: it looks like you may be trying to merge a dataset with a dataset that doesn't exist already. The first time you go through the loop, the table you've named "selecationmerge" doesn't exist; in fact it's assigned to an empty string. Additionally it's awkward (and, ...
Try this piece of code. I do not think that you have to cast the mean/std to float. Try it out this way. Of course you need an Spatial Analyst, but since you are using RasterCalculator I think you have it.
from arcpy.sa import *
ws2 = r"C:\unsupervised_classification\output\raster_tagliati_su_flowacc"
Your script is a bit inconsistent in how it refers to the fGDB. Sometimes by full path, sometimes just using the database name alone.
To avoid this inconsistency, as well as to avoid errors due to typos, I usually assign the full path to a variable (eg, gdb). If you get a typo in your variable, its much easier to diagnose than a typo in a text string.
Try instead to put your list of buffered outputs into a list object. You might also set the workspace option before proceeded, otherwise ArcMap will send the output from the union to the default geodatabase.
arcpy.env.workspace = "path to output folder or geodatabase"
arcpy.Union_analysis([buffer1, buffer2, buffer3], buffered_area)
Or if you know the path ...
Looks like it is having trouble finding the files.
I use double backslash to get to my files.
See this reference which shows the valid and invalid path options
cvr_rasters will be a list of only raster names with no path/workspace. When you change workspace after it is created the rasters will not be found. Try adding path to each raster:
arcpy.env.workspace = CVR
cvr_rasters = arcpy.ListRasters()
cvr_rasters = [os.path.join(CVR, r) for r in cvr_rasters]
Same goes for lss_rasters since you change ...
I think to make your script work you should:
remove all the arcpy.Raster() calls
# Set names for optional output rasters, seems not working???
outDirectRad = arcpy.Raster(outNameDirect)
outDiffuseRad = arcpy.Raster(outNameDiff)
outDirectDur = arcpy.Raster(outNameDirDur)
change the call to arcpy.sa.AreaSolarRadiation like this:
# Execute ...
You may have the band name wrong, check them using arcpy.da.Describe, i.e.
print([child['catalogPath'] for child in arcpy.da.Describe(outExtractByMask)['children']])
I get the band names as 'Band_1' to 'Band_<N>'.
You could create a little function* to automatically pull out the band names, then your code would look something like:
import arcpy, ...
It has been a while since I post this question. The script has been updated since then and I post my answer in the following part for other users.
list = 
rows = arcpy.SearchCursor(bufferclip)
SumArea = bufferclip + "Area"
for row in rows:
area = row.getValue("Shape_Area")
SumArea = sum(list)
Problem with my code was that I was using the 'CopyFeatures_management' function, which seems to expect a 'Feature Class' but I was trying to copy a static table. The code below copies static tables and is working for me.
When I run this code snippet (that I pulled from the code that you have presented) it appears that having a space in the pathname does not cause it to fail:
pointfc = r"C:\Temp space\TestProject\TestProject.gdb\pointfc"
outputCSV = r"C:\Temp space\test.csv"
When I run this code it works too (the ...
First of all you have set your workspace to an MXD called Ronan_Test. A workspace is a folder or geodatabase. So firstly I suggest you read the help file so you understand what and how to use the workspace environment correctly.
The error is exactly what it is, you can't create an INFO table with the file paths you are using. Whoever allowed such path names ...
Your problem is identified in the 1st parameter of SaveToLayerFile as ERROR 000732, meaning the input layer (Layer_17011) "does not exist or is not supported".
Not sure, but think the key is in that SaveToLayerFile expects a Layer data type - MakeFeatureLayer outputs a Feature Layer data type. According to the documentation, you can use getOutput(0) to ...
Your X-Maximum, Y-Maximum values are the same so you are not providing a valid rectangle. Recheck the bounding extent of your area and try again.
Try the following adjustment to your code. Per the documentation for arcpy.mapping.layer, this line is looking for a layer instead of a feature class. You already tried to create a layer (arcpy.MakeFeatureLayer_management) first, but you are referencing the feature class again instead of the layer.
arcpy.env.workspace = r"C:\arcgis\...
Symbology applies to a layer, not to a feature class. From the help:
This tool applies the symbology from a layer to the Input Layer. It
can be applied to feature, raster, network analysis, TIN, and
geostatistical layer files or layers in the ArcMap table of contents.
You will need to make a feature layer within your code (the following is untested ...