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
|
735
|
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
|
1232
|
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
|
1232
|
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
|
1797
|
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
|
1797
|
POST
|
Would be helpful if you could put up a image of your model, as well as what the inputs and outputs for the model, and the error code it threw.
... View more
04-14-2014
07:46 AM
|
0
|
0
|
378
|
POST
|
I would suggest using an open source tool. LASTools is a great open source tool for handling and converting LAS files. http://www.cs.unc.edu/~isenburg/lastools/ You would need to use the LAS2TXT function and you could get an ascii text file of the lidar data.
... View more
04-14-2014
05:56 AM
|
0
|
0
|
9065
|
POST
|
I put the script in a code block - It is not telling me the error. I am new to python, and I just threw this script together by reading other python scripts. Let me know if you need more info # Developed by: David Bailey
# Description: Providence Creek Watershed: land cover processing
# import arcpy site-package and os module
import arcpy, os
# Set geoprocessing environment:
# a) set the workspace environment
aWS = r"C:\Thesis_Research\GIS\Prov_classification.gdb"
arcpy.env.workspace = aWS
# Set geoprocessing environment:
# b) the overwriteOutput parameter controls whether tools will
# automatically overwrite any existing output
arcpy.env.overwriteOutput = True
try:
# Create query statements for each land cover type
LIDAR_tree = '"grid_code" > \'3\''
LIDAR_shrub = '"grid_code" = \'2\' OR "grid_code" = \'3\''
LIDAR_ground = '"grid_code" <= \'1\''
aListLIDAR = [LIDAR_tree, LIDAR_shrub, LIDAR_ground]
for item in aListLIDAR:
arcpy.MakeFeatureLayer_management("P303_LIDAR_Poly", P303_layerL)
arcpy.SelectLayerByAttribute_management(P303_layerL, "NEW_SELECTION", aListLIDAR)
arcpy.CopyFeatures_management(P303_layerL, "P303_" + str(item))
del aListLIDAR
del item
del P303_layerL
except:
# Code to run when an error occured
print "An ERROR Occured!"
print "\n" + arcpy.GetMessages()
else:
# Message when there was no error
print "\nNo Error occurred"
# Script end message
print "\nEnd of the script!" A few questions and observations. First is "P303_LIDAR_Poly" a feature class that is directly within your geodatabase, or is it in a feature class within the feature dataset? If its in a feature dataset within the geodatabase, your environment for that part needs to be within that feature dataset it resides. Second, "arcpy.SelectLayerByAttribute_management(P303_layerL, "NEW_SELECTION", aListLIDAR)" is wrong. it should be "arcpy.SelectLayerByAttribute_management(P303_layerL, "NEW_SELECTION", item)". Right now it is using the whole list for your SQL expression, which is a list. You want it to run through each expression individually, so use item.
... View more
04-14-2014
05:34 AM
|
0
|
0
|
1450
|
POST
|
import arcpy
from arcpy import env
env.workspace = #"put the file path to the folder your shapefile is in here as a string"
cursor = arcpy.da.UpdateCursor(#"shapefile name" , "Field name that has the 1's and 0's")
for row in cursor:
if row[0] == 1:
cursor.deleteRow()
del row
del cursor
I'd make a copy of your shapefile first to test this on, there is no way to undo the delete row, so I would test it on the copy before applying it to the actual file.
... View more
04-11-2014
10:17 AM
|
0
|
0
|
2047
|
POST
|
I'd probably use an update cursor to evaluate the value of the field, then delete the row if it the field value equals 1. If you need some starter code let me know.
... View more
04-11-2014
06:01 AM
|
0
|
0
|
2047
|
POST
|
When you bring the kml in does it have a projection? If it doesn't you can simply georeference it using the georeference toolbar.
... View more
04-10-2014
01:21 PM
|
0
|
0
|
1900
|
POST
|
alternatively you could just leave the optional field off.
gp.CostPath_sa("samp_lyr", cd_name, bl_name, "cost_path", "BEST_SINGLE")
if not ArcGIS help says destination_field (Optional) "The field used to obtain values for the destination locations. Input feature data must contain at least one valid field." Make sure your input variables have a valid field.
... View more
04-10-2014
01:10 PM
|
0
|
0
|
1013
|
POST
|
This will probably take a bit of debugging, since I don't have a sample dataset to test on but this should run through each feature dataset in your gdb, copy your feature dataset to you AerialPhotographycoverage.gdb and then run through each feature class in your feature dataset make a buffer and save the buffer in the copied feature dataset in the aerialphotographycoverage.gdb.
# 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:
#setting new workspace to the feature dataset we are using
env.workspace = fd
arcpy.CopyManagement(fd , fdOutput + "/" + 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
Sorry those buffer parameters get a bit nasty at the end. I needed to set the output path and give each buffer a unique name so it doesn't crash because the same file name exists. Hope this does the trick for you!
... View more
04-10-2014
12:59 PM
|
0
|
0
|
1158
|
POST
|
I believe it would be because you are not going into each feature dataset and then listing feature classes. The example given assumes your feature classes are directly in the gdb, not in a feature dataset in a gdb. you would need to use arcpy.ListDatasets in there to fix
import arcpy, sys, os, traceback
arcpy.env.overwriteOutput = 1
# Set Workspace
arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive"
# Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces
# for the Feature Class we are interested in. This list of feature classes is set to listFCS
out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb"
# list for all feature classes from different GDBs to merge
fcToMerge = []
for ws in arcpy.ListWorkspaces("*", "FileGDB"):
arcpy.env.workspace = ws
print '\n\Searching in %s\n\n' %ws
for fd in arcpy.ListDatasets("*", "Feature")
arcpy.env.workspace = fd
print '\n\Searching in %s\n\n' %fd
listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD")
# create a list with full pathes to feature classes
listFCsFullPath =[]
for fc in listFCS:
listFCsFullPath.append(os.path.join(ws, fc))
fcToMerge += listFCsFullPath
# Now Merge all Feature Classes and export to the Output
arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD"))
Edit: I copied the old code from m.gasior and edited that one to work, so you will need to rework it from what I did for yours, but that should fix it.
... View more
04-10-2014
12:31 PM
|
0
|
0
|
779
|
POST
|
Ian, WOW. Thanks for the help, I do have feature classes with multiple records. Is it possible to work with that same code and modify it to work? The reason I have multiple datasets and feature classes is I am working with statewide data, and needed to be able to apply the state plane coordinates to each different area based on county, and then have feature classes based on towns. However, some towns have multiple flight lines so they required multiple records in the feature class. Currently I am working mostly with the ESRI Press Python Scripting for ArcGIS book. Are there any other resources you could recommend for a person new to programming to get a good start with. I need to preserve the feature datasets into the new geodatabase as well. How would that best fit into the script example you have given? Thanks again for your help, I'm really taken aback at how helpful the Python community as a whole is. Todd Howell You can you the copy the feature datasets with arcpy.Copy_management, which can be put in the python script, probably while you are looping through feature datasets. THis is one problem arcpy.Buffer_analysis(fc, PhotoCoverages, distance, sideType, endType, dissolveType) as it needs to output to a feature class, which we have it outputting to a geodatabase, but its a pretty easy fix, but we need to make sure it has a different output name each time or it will crash. Busy at work right now, but I can help you out again in a bit. I'm pretty new to python myself, so not familiar with alot of good online resources, but arcgis help within ArcGIS is really handy for checking syntax and what your input and outputs for the methods are.
... View more
04-10-2014
09:44 AM
|
0
|
0
|
3103
|
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
|