POST
|
I have a dynamic coded script that runs as a tool. It utilizes arcpy.mapping to add some files to an existing template and then update the layer's symbology and name. I want to be able to differentiate between a couple different layers that have the same geometry but different names. For example, there could be a Polyline file for a Assignment Break, as well as a Polyline file for a fire line file. This is the code that I have input so far (it isn't working). code: shapesList = arcpy.mapping.ListLayers(mxd_Update, "*_lyr", mainDataFrame_Update) for shapes in shapesList: type = arcpy.Describe(shapes).shapetype.upper() name = arcpy.Describe(shapes).name.upper() if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*OLYGON*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_perimeter) arcpy.SelectLayerByAttribute_management(shapes, "NEW_SELECTION") mainDataFrame_Update.zoomToSelectedFeatures() arcpy.SelectLayerByAttribute_management(shapes, "CLEAR_SELECTION") shapes.name = "Fire Perimeter" if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*NTENSE*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, intense_heat) shapes.name = "Intense Heat" if type== "POLYGON" and name== fnmatch.fnmatch(shapes, "*CATTERED*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, scatter_heat) shapes.name = "Scattered Heat" if type== "POLYLINE" and name== fnmatch.fnmatch(shapes, "*SSIGNMENT*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, assign_break) shapes.name = "Assignment Break" if type== "POLYLINE" and name== fnmatch.fnmatch(shapes, "*IRE*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_line) shapes.name = "Fire Lines" if type== "POINT" and name== fnmatch.fnmatch(shapes, "*OINTS*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, fire_point) shapes.name = "Fire Points" if type== "POINT" and name== fnmatch.fnmatch(shapes, "*SOLATED*"): arcpy.mapping.UpdateLayer(mainDataFrame_Update, shapes, iso_heat) shapes.name = "Isolated Heat" else: print "no go fo sho tho" A couple of basic questions... you can't use two (*) to grab a group of text from the middle of a string, correct? I can't really get my head wrapped around how I would use the m. functions in re to get this done... and I also can't use fnmatch because it isn't a filename, correct? Either way, I'm in over my head on this little bit
... View more
02-20-2015
09:47 AM
|
0
|
1
|
4580
|
POST
|
Hello everyone, I seem to have hit a wall in my abilities once again. I have feature classes in two geodatabases. I am trying to iterate through the feature classes in the first geodatabase and based on the last 6 digits of the name find the matching feature class in the second geodatabase. Using the feature class from the first geodatabase in a for in loop and feature class in the second geodatabase that is located based on the last 6 digits of the feature class name, I would like to run the Locate Features Along Route tool using the first fc as the input and the second fc as the input route features. Is this possible? I'm not sure how to use ListFeatureClasses to list fc's in two separate geodatabases as it is environment dependent. Any help is greatly appreciated. Todd Howell
... View more
06-16-2014
12:53 PM
|
0
|
1
|
2136
|
POST
|
I'm thinking it might just be easier to start with a script that creates a field for the buffer distance in the feature classes first, also having a field calculator script to use in the future while digitizing the new flight lines. The cursor script for making the calculations seems to be where this is all getting hung up at, right?
... View more
05-08-2014
08:26 AM
|
0
|
0
|
866
|
POST
|
Ian, I have taken a few more ESRI online python trainings, I'm back to trying to debug this script. The current sticking point is as follows: >>> Eddy_County Traceback (most recent call last): File "C:\Python27\ArcGIS10.2\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 326, in RunScript exec codeObject in __main__.__dict__ File "C:\Users\thowe01\Desktop\IMURRAY_SCRIPT.py", line 39, in <module> distance = ((row.getValue(distanceField))*(multiplier)) File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\arcobjects\arcobjects.py", line 1064, in getValue return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args))) RuntimeError: ERROR 999999: Error executing function. I have a few questions/ideas about it as well. I'll wait until you see this before I go muddying the waters with my half cocked ideas though. Hope you are doing well. Todd
... View more
05-07-2014
12:53 PM
|
0
|
0
|
866
|
POST
|
Error: Runtime error Traceback (most recent call last): File "<string>", line 23, in <module> AttributeError: 'module' object has no attribute 'CopyManagement' I had noticed those indent errors when I debugged it in PythonWin. The above error is the same one that was returning on the previous script too. I'm not sure if the input and input can be geodatabases in the copy tool. I tried setting up the tool in ArcMap with the parameters specified in the script and it gave an error for the output being a geodatabase, and not wanting to overwrite the OutWorkspace gdb with the input gdb. Should I try to just keep the current workspace .gdb for archival purposes, copy the feature classes out to a working gdb for the sake of simplifying the geoprocessing (removing the element of feature datasets). I think I'm going to write a script for creating a field with the calculated values for the buffer input to simplify that part of the code a bit too. What are your thoughts? Thank you very very much for all your help. I really appreciate you taking your time to teach me so much.
... View more
04-15-2014
01:08 PM
|
0
|
0
|
866
|
POST
|
So I am getting a error returned for Line 23 which is where the Copy Management tool is called. In messing with the parameters in the tool to see what I could get to work, I had to call a specific feature dataset as the input and then the output could be just the OutWorkspace database. So, I think then the sticking point is creating another for in loop from a dataset list that would process the datasets into the target geodatabase, or is that going to copy over all the feature classes too? I'm sorry for being so bad at this, I'm really new, and took on a pretty ambitious project for my limited abilities. 🙂
... View more
04-15-2014
11:09 AM
|
0
|
0
|
866
|
POST
|
Runtime error Traceback (most recent call last): File "<string>", line 35, in <module> File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\arcobjects\arcobjects.py", line 1064, in getValue return convertArcObjectToPythonObject(self._arc_object.GetValue(*gp_fixargs(args))) RuntimeError: ERROR 999999: Error executing function. I'm having trouble figuring out why it is returning this error when I try to run that code in ArcGIS as well.
... View more
04-10-2014
06:04 AM
|
0
|
0
|
2417
|
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
... View more
04-10-2014
05:51 AM
|
0
|
0
|
2417
|
POST
|
Thanks Greg! I appreciate the feedback. How exactly do I establish the geodatabase as a list for input into a for loop? Is there any way to preserve the feature datasets so that they transfer into the output geodatabase once the feature classes are processed through the buffer tool?
... View more
04-09-2014
09:18 AM
|
0
|
0
|
2417
|
POST
|
I am very new to python, and am trying to utilize a stand alone script that I can use on a working geodatabase full of feature classes in various feature datasets. Here's what I'm trying to accomplish, and the script that I have constructed. 1. I have a file geodatabase full of feature datasets based on county, inside of the county feature datasets I have feature classes that represent the center of aerial photography flight lines. These feature classes have a field that contains the flight height of the photography. 2. I have constructed a script that so far is unsuccessful at what I want it to accomplish. My goal is to have a script that will batch process all of the feature classes in the geodatabase, will create buffers of the lines contained in those feature classes based on the flight height field which needs to be multiplied by a factor of 1.502167099846. Then output into my separate geodatabase that will contain those photo coverages for use with an ArcGIS online map service. Here is the script that I have constructed thus far: # 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 Flightlines = "J:\Flight_Lines_GDB\Flight_Lines_Coverages.gdb" PhotoCoverages = "J:\Aerial_Photo_GDB\Aerial_Photography_Coverage.gdb" distanceField = "Flight_Height" sideType = "FULL" endType = "FLAT" dissolveType = "NONE" arcpy.Buffer_analysis(Flightlines, PhotoCoverages, distanceField, sideType, endType, dissolveType) Things I know. - I cannot just input the geodatabase as an input in the buffer tool, but I am unsure how to accomplish a loop or the like to process through all of the feature classes in the geodatabase. -I cannot multiply a the field that I want to input as the buffer distance by a number either when I am defining it or in the tool parameters. -I am a bit in over my head, and I am very very thankful for anyone with the patience and gracious nature to help me in any way. Thanks for looking at this, I appreciate any help you can give. Todd Howell
... View more
04-09-2014
08:09 AM
|
0
|
18
|
10240
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|