|
POST
|
I was thinking the same thing Kevin. From the error code it looks like it was having an issue with the fnmatch module, which it was trying to get from the python26 folder.
... View more
05-09-2014
08:18 AM
|
0
|
0
|
1324
|
|
POST
|
I believe when you install a more recent version of ArcGIS it automatically uninstalls the older version as it installs the newer version. So yes it was probably not the best idea to manually uninstall 10.0 prior to installing 10.1. What the effect of this would be I wouldn't know though.
... View more
05-09-2014
07:06 AM
|
0
|
0
|
1324
|
|
POST
|
Got another idea for taking care of that getting that field value. We just have the cursor only iterate through that field so when we set the cursor, set the feature class, then fields you want in brackets, if you needed more then one you can comma seperate each field name(they need to be strings and all inside the brackets). cursor = arcpy.SearchCursor(fc, ["distanceField"]). In the loop calling an index value on row will not refer back to the original field number i.e. if this was column 5 in your attribute table or index value 4, now it is index value 0(first one in the cursor). If you had another field you were going to iterate through with the cursor listed after this one(say ID field) that would be index value 1, etc. So I put in distance = int(row[0])*(multiplier)) in the for loop instead. # 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, ["distanceField"]) count = 1 for row in cursor: distance = float(row[0])*(multiplier)) arcpy.Buffer_analysis(fc, FCOutput + "/" + fc + "_Buffer" + str(count) , distance, sideType, endType, dissolveType) count += 1 del row del cursor
... View more
05-08-2014
02:09 PM
|
0
|
0
|
6520
|
|
POST
|
Karl, I'm not sure this is the problem, but I thought it was worth point out. arcpy.PointToRaster_conversion(feature class name, "Value", out data name, "MEAN", "Vaule", 10000) First you have a syntax error I'm assuming "Vaule" should be "Value". Secondly, the 5th parameter, which is priority field should only be used when you use the MOST_FREQUENT cell assignment(4th parameter). It should probably left just a blank string when you use "Mean" cell assignment. This may or may not have anything to do with you getting the wrong values. arcpy.PointToRaster_conversion(feature class name, "Value", out data name, "MEAN", "", 10000)
... View more
04-18-2014
09:13 AM
|
0
|
0
|
777
|
|
POST
|
whereClause = "\"STATION_ID\" = 'CAP', 'DDM'" So you want to select if station id is CAP or DDM? I'm not sure you can comma separate those it might need to be whereClause = "\"STATION_ID\" = 'CAP' OR "\"STATION_ID\"= 'DDM'" See if that works
... View more
04-16-2014
10:18 AM
|
0
|
0
|
1783
|
|
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
|
2314
|
|
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
|
1823
|
|
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
|
1823
|
|
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
|
1293
|
|
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
|
1219
|
|
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
|
1219
|
|
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
|
1219
|
|
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
|
1219
|
|
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
|
306
|
|
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
|
1293
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-22-2017 08:58 AM | |
| 1 | 10-05-2015 05:43 AM | |
| 1 | 05-08-2015 07:03 AM | |
| 1 | 10-20-2015 02:20 PM | |
| 1 | 10-05-2015 05:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|