POST
|
arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", "temp_layer", where_clause=query) should probably be arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", "temp_layer", query) As I recall, you don't have to put the word where_clause in the parameters, its understood since its the 3rd parameter for make feature layer. Also Matt In your arcpy.MakeFeatureLayer_management method, your outlayer is being written to a variable "P303_layerL" that was never declared anywhere, that would certainly throw an error. its not being written to a variable, its a string, and since its an output parameter, it doesn't need to exist already, you are just naming your output layer name, it no different then what you changed it to. "temp_layer" has no special meaning, its just a name you are giving it to store in memory.
... View more
04-16-2014
06:09 AM
|
0
|
0
|
1282
|
POST
|
Now I feel like an idiot. CopyManagement should have been Copy_management. Replace that and it should work(at least past that point)
... View more
04-15-2014
01:49 PM
|
0
|
0
|
968
|
POST
|
Some of my indents were off, and I changed the environment before copying the feature datasets. I tweaked it a bit, and hopefully it will run. Next time if there is an error, post the error message, it will help with debugging.
# Name: Flight_Line_Buffer.py
# Description: Creates area of Aerial Photography coverage based on digitized flight lines, and associated flight height field in flight line table.
#Import system modules
import arcpy
from arcpy import env
# Set environment settings
env.workspace = "J:\Flight_Lines_GDB\Flight_Lines_Coverage.gdb"
env.Outworkspace = "J:\Aerial_Photo_GDB\Aerial_Photography_Coverage.gdb"
# Create buffer distance output from Flight Height field, and buffer flight lines
PhotoCoverages = "J:\Aerial_Photo_GDB\Aerial_Photography_Coverage.gdb"
fdOutput = "J:\Aerial_Photo_GDB\Aerial_Photography_Coverage.gdb"
#fetches all feaure datasets in workspace into a list
fdlist = arcpy.ListDatasets()
# loop through feature datasets in the list
for fd in fdlist:
print fd
#setting new workspace to the feature dataset we are using
arcpy.CopyManagement(fd , fdOutput + "/" + fd)
env.workspace = fd
# fetches all feature classes in workspace into a list
fclist = arcpy.ListFeatureClasses()
#loop through feature classes in our list
for fc in fclist:
FCOutput = fdOutput + "/" + fd
distanceField = "Flight_Height"
sideType = "FULL"
endType = "FLAT"
dissolveType = "NONE"
multiplier = 1.502167099846
cursor = arcpy.SearchCursor(fc)
count = 1
for row in cursor:
distance = ((row.getValue(distanceField))*(multiplier))
arcpy.Buffer_analysis(fc, FCOutput + "/" + fc + "_Buffer" + str(count) , distance, sideType, endType, dissolveType)
count += 1
del row
del cursor
... View more
04-15-2014
11:57 AM
|
0
|
0
|
968
|
POST
|
Yes, that would be the problem. I only ever saw the "Property" so I didn't realize you were using commas instead of periods. When you use commas, that is how it separates parameters, so it thought you were giving 2 inputs instead of one. Mark this as answered since you got it figured out.
... View more
04-15-2014
10:22 AM
|
0
|
0
|
585
|
POST
|
Hello Giovanni, You're off to a good start. I made a few changes: import datetime
import arcpy
def getDateFromFile(f):
return f.split('_arc')[1][:8] #gets the first 8 characters after "_arc"
def getJulian(d):
dt = datetime.datetime.strptime(d, '%Y%m%d')
return str(dt.timetuple().tm_yday).zfill(3)
arcpy.env.workspace = "e:/Pyton/prova/Tif"
outDirectory = "e:/Pyton/prova/bil" #should not need the blackets
datasetList = arcpy.ListDatasets("*", "Raster")
for tif in datasetList:
date=getDateFromFile(tif) #calls on function defined above
year=date[:4] #gets first 4 characters of date
outRast = "rain_"+year+getJulian(date)+".bil"
outBil = outDirectory + "/" + outRast
print "Copying "+tif+" to "+outRast+"..."
arcpy.CopyRaster_management(tif,outBil) For the future, you must start an if statement with "if", not "elif". Let me know if it works for you or if you have any questions about it. Good luck! ~Josh Thanks Josh, I wasn't familiar enough with datetime to want to try to write that out for him. I was in the middle of trying to do some painful if, elif statements to calculate Julian dates from the YYYYMMDD from those file names. Especially when you have to consider leapyears, its a big pain.
... View more
04-15-2014
10:12 AM
|
0
|
0
|
558
|
POST
|
You cannot have just start with an elif statement. You must start with if statement, then have elif statement for subsequent queries, until you end with an else statement. This would be much simpler if your output could be YYYYMMDD same as your input raster. All you would have to do is take the ending from your input file, store is as string and concatenate it onto the end of your output raster. Using that many elif statements just isn't a smart way to go about this.
... View more
04-15-2014
10:01 AM
|
0
|
0
|
558
|
POST
|
You cannot have just start with an elif statement. You must start with if statement, then have elif statement for subsequent queries, until you end with an else statement. Btw your idea of that many elif statements is crazy. There is an easier way to do this. import arcpy arcpy.env.workspace = "e:/Pyton/prova/Tif" outLoc = ("e:/Pyton/prova/bil") outDirectory = outLoc datasetList = arcpy.ListDatasets("*", "Raster") #Looping through all rasters for d in datasetList: # storing input raster name tif = str(d) d = d.split("_") d = d[-1] print d outRast = "rain_" + d + ".bil" outD = outDirectory + "/" + outRast arcpy.CopyRaster_management(tif,outD)
... View more
04-15-2014
09:50 AM
|
0
|
0
|
558
|
POST
|
You cannot have just start with an elif statement. You must start with if statement, then have elif statement for subsequent queries, until you end with an else statement. Btw your idea of that many elif statements is crazy. There is an easier way to do this. import arcpy arcpy.env.workspace = "e:/Pyton/prova/Tif" outLoc = ("e:/Pyton/prova/bil") outDirectory = outLoc datasetList = arcpy.ListDatasets("*", "Raster") for d in datasetList: tif = str(d) d = d.split("_") d = d[-1] outRast = "rain_" + d + ".bil" outD = outDirectory + "/" + outRast
... View more
04-15-2014
09:48 AM
|
0
|
0
|
558
|
POST
|
I'm not sure there is a Model builder solution for this, but it definitely can be done in python.
... View more
04-15-2014
09:35 AM
|
0
|
0
|
131
|
POST
|
I'm guessing Property is the field name you are evaluating? The problem would be the field type then, since it is listed as float. I would see if you can change the field type to Double.
... View more
04-15-2014
09:25 AM
|
0
|
0
|
585
|
POST
|
Looking at ArcGIS help, it looks like you can't use float value in your expression in model builder. Make sure you use a supported variable type. http://resources.arcgis.com/en/help/main/10.1/index.html#//009z000000z7000000
... View more
04-15-2014
09:00 AM
|
0
|
0
|
585
|
POST
|
So just to confirm, arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp","TotalArea","!Shape.area!","PYTHON","#") To this: arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp","TotalArea","!Shape.area!","PYTHON") I had him do that in the code I wrote him, so I don't think that's the issue.
... View more
04-14-2014
10:03 AM
|
0
|
0
|
1043
|
POST
|
Yes, like i said when i used the caluclate filed python expression the script works, but it crashes when it finish working. I can open the shapefile and see all the fields and their values. Now i dont know why python crashes when i do this and i dont know how to debug something like this. Yea, that's significantly uglier than I was expected, I didn't realize when you said "crash" you meant crash like that. Reminds me of the time I had a script that would just stop in different places, it would process between 30-40 files (out of like 600) and then just stop, no error codes, no nothing, just would stop, and in a different place each time. First time 25 files, next 40, next 32. Finally got a computer with a better processer and more memory and it managed to do all of the files in one go.
... View more
04-14-2014
09:07 AM
|
0
|
0
|
1043
|
POST
|
Hello Daniel, I don't think you can calculate area with VB. It might be better to use Python and try to figure out why it's crashing (what error are you getting?). I would use something like: arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp","TotalArea","!Shape.area!","PYTHON","#") Also, one quick question, the field "TotalArea" exists before you calculate field right? I was thinking the same thing, I'd rather know why my code is not working then try to find a run around for it. Also, make sure the field names match up, it is case sensitive.
... View more
04-14-2014
08:42 AM
|
0
|
0
|
1580
|
POST
|
I couldn't get it working with VB, but here is a valid python expression arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp", "totalArea" , "!shape.area!", "PYTHON") I tested it on an existing file I had, and it calculated the same area that already existed for that shapefile.
... View more
04-14-2014
08:33 AM
|
0
|
0
|
1580
|
Title | Kudos | Posted |
---|---|---|
1 | 02-22-2017 08:58 AM | |
1 | 01-19-2017 09:34 AM | |
1 | 07-26-2017 12:56 PM | |
1 | 04-11-2018 12:35 PM | |
1 | 06-16-2015 07:59 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|