POST
|
For anyone still curious, see this: http://solutions.arcgis.com/local-government/help/fire-run-book/ The below was copied from that page: Fire Run Book is supported on ArcGIS 10.1, 10.2 and 10.3. Requirement Description Experience Map production workflows in ArcGIS for Desktop Software Map Authoring ArcGIS for Desktop (Basic, Standard or Advanced) ReportLab 2.7 for Python 2.7 32-bit Note ReportLab 2.7 for Python 2.7 64-bit is required to run the Fire Run Book tools using 64-bit background geoprocessing.
... View more
05-04-2015
09:08 AM
|
0
|
1
|
536
|
POST
|
You are correct (and so is Dan). Based on your results, the problem is with the CASE statement. I tested the same datasource (file gdb) at both 10.0 and 10.2.1 -- the 10.0 test failed with the file gdb source but passed with an sde source; no problems at all with 10.2.1. So what I suggest to help make this easier on yourself is (if you can) calculate a new 'dummy' field (integer type) just to hold this CASE result, conditionally calculating the 2nd compound clause, this part: (CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) You should be able to do that with, say, a simple Python code block in the field calculator, something simple like the below - there's a less tedious way to write this function in more condensed 'pythonic' form, but this way you can more readily see what it's doing - this is the code block:
def subQry(yr84, yr86, yr87, yr91, yr00, yr03, yr06, yr11):
counter = 0
if yr84 == 1:
counter += 1
if yr86 == 1:
counter += 1
if yr87 == 1:
counter += 1
if yr91 == 1:
counter += 1
if yr00 == 1:
counter += 1
if yr03 == 1:
counter += 1
if yr06 == 1:
counter += 1
if yr11 == 1:
counter += 1
return counter
...and of course in the field calculator you'd check on the Python parser, and enter this expression statement to pass your fields: subQry(!1984!, !1986!, !1987!, !1991!, !2000!, !2003!, !2006!, !2011!)
Then, say your 'dummy' field is called 'yourNewField', then your new SQL query based on this calculation should be valid (oops, previously I forgot the double-quote delimiters on "yourNewField", now corrected): NOT "2003"=3 AND NOT "2006" =3 AND "2011"=3 AND "yourNewField" >= 3
... View more
07-23-2014
04:32 AM
|
0
|
1
|
873
|
POST
|
Hi Caroline, You haven't answered the specifics of your error - are you still having the 'invalid SQL statement' error? Also, you didn't say what version of ArcGIS and db source you're using (or I missed it). Anyway, for what it's worth, you have to be careful with your logic and your statement is getting pretty long, perhaps convoluted. Consider this, with my above SQL query example - similar to yours, I am combining clauses that all must eval to True to select the record, that is everything within the 'compound' clause and everything without as well. That means when you connect with 'AND' 1 clause you know works to another clause, both must evaluate to True to make the selection. See this, which for my dataset only selected a single record (to illustrate the concept): (NOT "RNG" = 33 AND NOT "RNG" = 34 AND "TWP" = 62) AND (CASE WHEN "RNG" >= 32 AND "RNG" <= 35 THEN 1 ELSE 0 END + CASE WHEN "TWP" >= 62 AND "TWP" <= 66 THEN 1 ELSE 0 END + CASE WHEN "LOCATION" LIKE '%VACANT%' THEN 0 ELSE 1 END) = 3 This is because not only does the 2nd clause (= 3) have to be satisfied, but so does the 1st. It must not contain those records where the range is 33 nor 34. Not only that but with '...AND "TWP" = 62', that restricts the entire results to the township coded 62 only. So if your SQL is not in error (the above query works at 10.2.1), then check your logic. -Wayne
... View more
07-22-2014
08:37 AM
|
0
|
4
|
873
|
POST
|
Could be a simple mistake, can you post a picture or code block if that is how you're running it? Also, what version ArcGIS are you using and what DB platform are you running against? You are using the Spatial Analyst tool, correct? (although that should not matter - should accept SQL) As an initial guess, I think maybe you're not passing the query to the tool as a string - for example, when I run in Python a similar kind of SQL, notice it is a string (here I'm entering the backslash line continuation character for better readability):
>>> qry = '(CASE WHEN "RNG" >= 32 AND "RNG" <= 35 THEN 1 ELSE 0 END + \
CASE WHEN "TWP" >= 62 AND "TWP" <= 66 THEN 1 ELSE 0 END + \
CASE WHEN "LOCATION" LIKE \'%VACANT%\' THEN 0 ELSE 1 END) = 3'
>>>
>>>
>>> fc = r'C:\Users\whitley-wayne\Desktop\data_backup05131551.gdb\parcels20140102'
>>> import arcpy
>>> arcpy.MakeFeatureLayer_management(fc, 'testLyr', qry)
<Result 'testLyr'>
>>> theCount = arcpy.GetCount_management('testLyr')
>>> theCount.getOutput(0)
u'9485'
>>>
Your query string is fairly long, but I see nothing wrong with passing it as a single-line string, for example:
>>> where_clause = '(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) >= 3'
>>>
>>> print where_clause
(CASE WHEN "1984" =1 THEN 1 ELSE 0 END + CASE WHEN "1986" = 1 THEN 1 ELSE 0 END + CASE WHEN "1987" = 1 THEN 1 ELSE 0 END + CASE WHEN "1991" = 1 THEN 1 ELSE 0 END + CASE WHEN "2000" = 1 THEN 1 ELSE 0 END + CASE WHEN "2003" = 1 THEN 1 ELSE 0 END + CASE WHEN "2006" = 1 THEN 1 ELSE 0 END + CASE WHEN "2011" = 1 THEN 1 ELSE 0 END) >= 3
>>>
... View more
07-21-2014
01:31 PM
|
1
|
6
|
873
|
POST
|
Looks to me, if I understand correctly your logic, you are simply missing the plus operator, like so:
(CASE WHEN "1984" =1 THEN 1 ELSE 0 END +
CASE WHEN "1986" = 1 THEN 1 ELSE 0 END +
CASE WHEN "1987" = 1 THEN 1 ELSE 0 END +
CASE WHEN "1991" = 1 THEN 1 ELSE 0 END +
CASE WHEN "2000" = 1 THEN 1 ELSE 0 END +
CASE WHEN "2003" = 1 THEN 1 ELSE 0 END +
CASE WHEN "2006" = 1 THEN 1 ELSE 0 END +
CASE WHEN "2011" = 1 THEN 1 ELSE 0 END)
>= 3
All you need is for the entire query to return True or False...but the way you have it set up testing each field conditionally, each field tested for the numeric value 1 will individually test True or False -- if True, you are assigning a value of 1, so if you want to test whether at least 3 of them eval to 1 then you have to add their respective results together. Looks like you had a little mistake toward the end too with 'THEN ELSE' (no value assigned for THEN). Oh, almost forgot, when you use the 'AND', you're not adding...that would check for something like TRUE AND TRUE AND FALSE which would then be FALSE for the whole thing (wouldn't make sense to compare to 3). -Wayne PS- I suppose another example could be useful - certainly not the only way to run such a query, but this one applies similar SQL logic to select parcels in a subarea (by Township and Range) that are not coded (partial string) VACANT in a LOCATION field - this is Python using a SQL query in the SelectLayerByAttribute tool:
>>> qry = '(CASE WHEN "RNG" >= 32 AND "RNG" <= 35 THEN 1 ELSE 0 END + CASE WHEN "TWP" >= 62 AND "TWP" <= 66 THEN 1 ELSE 0 END + CASE WHEN "LOCATION" LIKE \'%VACANT%\' THEN 0 ELSE 1 END) = 3'
>>> arcpy.SelectLayerByAttribute_management("parcels20140102", "NEW_SELECTION", qry)
<Result 'parcels20140102'>
>>>
... View more
07-21-2014
12:53 PM
|
1
|
8
|
873
|
POST
|
I got more time to look at this problem again - 3 things I really did not like about the last solution I posted are: - This was first tried as a 10.0 solution, so I didn't have access to the 10.2.x geometry methods, boundary() and cut(cutter). - I couldn't think of a 'lower license' solution to 'reconstruct' the oval polygon into 2 bisected parts and resorted to using Feature To Polygon. - Unfortunately the bisecting line geometry constructed didn't work until I 'fiddled' with the cluster tolerance - this introduced some error. I have another machine with 10.2.1 installed that yields a better solution (lower license) without introducing error. Just being lazy before, but a simple solution to overcoming the cluster tolerance challenge is to use a little algebra on the bisecting line to extend it enough to effectively use it as a 'cutter'. This bit of code (within IDLE) then 'corrects' the 'bisect' line geometry:
>>> # recall (from the previous post) the point coordinates derived from the MBG output
>>> print pt1X;pt1Y;pt2X;pt2Y
536180.987517
122898.58987617493
537308.88880471326
123781.06596555188
>>>
>>> slope = (pt2Y - pt1Y)/(pt2X - pt1X)
>>> print slope
0.782405427813
>>>
>>> # Y2 - Y1 = slope(X2 - X1)
>>> # Then, say, delta X is 1 unit...then Y2 - Y1 = slope.
>>>
>>> pt1Xext = pt1X -1.0
>>> pt2Xext = pt2X +1.0
>>> print pt1Xext;pt2Xext
536179.987517
537309.88880471326
>>>
>>> # Y2 = slope + Y1
>>> pt1Yext = -slope + pt1Y
>>> print pt1Yext
122897.807471
>>>
>>> pt2Yext = pt2Y + slope
>>> print pt2Yext
123781.848371
>>>
>>> # now load the 'corrected' coords into point objs
>>> pt1 = arcpy.Point(pt1Xext,pt1Yext)
>>> pt2 = arcpy.Point(pt2Xext,pt2Yext)
>>> newArray = arcpy.Array()
>>> newArray.add(pt1);newArray.add(pt2)
>>>
>>> # from the array, create the line geom
>>> bisect = arcpy.Polyline(newArray)
...here's where it gets interesting - I access the original oval shape to be cut, but unfortunately I run into a spatial reference required on 'bisect' is missing when trying to make the 'cut' (or bisect):
>>> # same 10.0 command (old-style cursor)
>>> rows2 = arcpy.SearchCursor('ovalTendingNEtoSW')
>>> row2 = rows2.next()
>>> feat2 = row2.shape
>>> type(feat2)
<class 'arcpy.arcobjects.geometries.Polygon'>
>>>
>>> # now try the 'new' geom methods
>>> feat2bound = feat2.boundary()
>>>
>>> # 'bisect' is the 'cutter':
>>> # cut(cutter)
>>> theBisected = feat2bound.cut(bisect)
Traceback (most recent call last):
File "<pyshell#43>", line 1, in <module>
theBisected = feat2bound.cut(bisect)
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\arcobjects\arcobjects.py", line 825, in cut
return convertArcObjectToPythonObject(self._arc_object.Cut(*gp_fixargs((other,))))
RuntimeError: All geometries involved in this operation must have the same spatial reference.
So, this was corrected...the bisect was accomplished - without the need for a higher license (and without the tolerance error).
>>> feat2.spatialReference.PCSName
u'NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901_Feet'
>>> bisect.spatialReference.PCSName
u''
>>> feat2.spatialReference.PCSCode
2881
>>> feat2.spatialReference.factoryCode
2881
>>> sr = arcpy.SpatialReference(2881)
>>> sr.PCSName
u'NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901_Feet'
>>>
>>> # build 'bisect' with a spatial reference
>>> bisect = arcpy.Polyline(newArray, sr)
>>> bisect.spatialReference.PCSName
u'NAD_1983_HARN_StatePlane_Florida_East_FIPS_0901_Feet'
>>>
>>> # no fuss now (hopefully)
>>> theBisected = feat2.cut(bisect)
>>>
>>> type(theBisected)
<type 'list'>
>>> for eachGeom in theBisected:
print str(type(eachGeom))
<class 'arcpy.arcobjects.geometries.Polygon'>
<class 'arcpy.arcobjects.geometries.Polygon'>
>>> theBisectedLeft = theBisected[0].boundary()
>>> theBisectedRight = theBisected[1].boundary()
>>>
>>> # copy the results to gdb
>>> arcpy.Merge_management([theBisectedLeft,theBisectedRight],'bisectedOvalBoundary')
<Result '\\\\MC-GISAPPSERVER\\mapdocs\\temp\\testData.gdb\\bisectedOvalBoundary'>
>>>
>>> # not quite yet, but close...
>>> # need the bisection of the orig boundary poly; not the boundaries of the bisected polys
>>> theBisected = feat2bound.cut(bisect)
>>> arcpy.Merge_management([theBisected[0],theBisected[1]],'bisectedOvalBoundary2')
<Result '\\\\MC-GISAPPSERVER\\mapdocs\\temp\\testData.gdb\\bisectedOvalBoundary2'>
>>> # ah, beautiful!
... View more
07-09-2014
03:59 PM
|
0
|
1
|
463
|
POST
|
...first post on GeoNet, thought I'd use this thread (hope you don't mind Noah) to try out the experience on the new forum format. Since this seems to be a one-off, I'll even try posting some really rough code below that was constructed interactively (IDLE), but 1st I'll explain the so-called solution. This may not be good, but it's what came to mind - here it is in basically 3 steps: 1- In the Features toolset (Data Management toolbox), use Minimum Bounding Geometry with the RECTANGLE_BY_AREA geometry type (basic licence level)... (This part is what is actually shown in the code section below, working on the Min Bound Geom result.) 2- With the known 4 corners of the 'bounding polygon' output, extract the midpoints along the major axis... 3- use some geometry methods and some kind of overlay processing to 'split' the orig poly. I apologize firsthand for what I resorted to doing in the final step 3, kind of lost the handle on what I was doing and cheated a little using an 'advanced' (and probably inefficient for this use case) couple of heavyduty Feature To Polygon and Feature To Line tool executions (since you wanted the 'oval' outline in 2 line 'mirrored' parts, if I understood correctly?)...yeah, I know, failed to do it all with the lower license and I know well there's a workaround in order to complete the task, but frankly it's beer-thirty and I'm thirsty. If it cripples you at the last step I can help out tomorrow, but it does the trick with just ver 10.0 (easily adapted to more advanced techniques via 10.2.x). Okay, remember this was only meant for a one-off, no polish whatsoever, and only meant as a demo to help furnish you an idea how to go about this problem. Of course this could be dramatically shortened, and improved esp where I failed to include the final hack converting the geom without requiring a higher-than-Basic Desktop license...maybe someone else will do that. Enjoy, Wayne ...so let's see if I can figure out how to paste this rough-hacked solution:
>>> rows = arcpy.SearchCursor("the MinimumBoundingGeometry result on your oval shape")
>>> row = rows.next()
>>> feat = row.Shape
>>> for point in feat.getPart(0):
... print point.X, point.Y
...
535920.293977 123231.784748
537048.195264 124114.261001
537569.582345 123447.87093
536441.681058 122565.395005
535920.293977 123231.784748
>>> anArray = feat.getPart(0)
>>> for i in range(4):
... print anArray.getObject(i)
...
535920.293976922 123231.784747839 NaN NaN
537048.195264421 124114.261001259 NaN NaN
537569.582345005 123447.870929845 NaN NaN
536441.681057505 122565.395004511 NaN NaN
>>> newArray = arcpy.Array()
>>>
>>> # coords of bisect line
>>> pt1X = anArray.getObject(0).X + (anArray.getObject(3).X - anArray.getObject(0).X)/2
>>> print pt1X
536180.987517
>>> pt1Y = anArray.getObject(3).Y + (anArray.getObject(0).Y - anArray.getObject(3).Y)/2
>>> print pt1Y
122898.589876
>>>
>>> # now pt2 to form the other line endpoint...
>>> pt2X = anArray.getObject(1).X + (anArray.getObject(2).X - anArray.getObject(1).X)/2
>>> print pt2X
537308.888805
>>> pt2Y = anArray.getObject(2).Y + (anArray.getObject(1).Y - anArray.getObject(2).Y)/2
>>> print pt2Y
123781.065966
>>>
>>> # create the points...
>>> pt1 = arcpy.Point(pt1X,pt1Y)
>>> pt2 = arcpy.Point(pt2X,pt2Y)
>>>
>>> # add the points to the new array...
>>> newArray.add(pt1);newArray.add(pt2)
>>>
>>> # create the line geometry...
>>> bisect = arcpy.Polyline(newArray)
>>> arcpy.env.workspace = r'C:\Users\whitley-wayne\Documents\ArcGIS\Default.gdb'
>>> arcpy.env.overwriteOutput = True
>>> arcpy.CopyFeatures_management(bisect, 'bisectingLine')
<Result 'C:\\Users\\whitley-wayne\\Documents\\ArcGIS\\Default.gdb\\bisectingLine'>
>>>
>>> # define in_features, out_feature_class
>>> in_features = ['ovalTendingNEtoSW', 'bisectingLine']
>>> out_feature_class = 'bisectedPoly'
>>>
>>> # try the union again with geom copied to line fc:
>>> arcpy.Union_analysis (in_features, out_feature_class)
Runtime error <class 'arcgisscripting.ExecuteError'>: ERROR 000366: Invalid geometry type
>>> # wrong gp tool with ERROR 000366, try feat to poly...
>>> # FeatureToPolygon_management (in_features, out_feature_class, {cluster_tolerance}, {attributes}, {label_features})
>>> arcpy.FeatureToPolygon_management (in_features, out_feature_class)
<Result 'C:\\Users\\whitley-wayne\\Documents\\ArcGIS\\Default.gdb\\bisectedPoly'>
>>>
>>> # didn't work; try increasing the cluster tolerance...
>>> arcpy.FeatureToPolygon_management (in_features, out_feature_class, '1')
<Result 'C:\\Users\\whitley-wayne\\Documents\\ArcGIS\\Default.gdb\\bisectedPoly'>
>>>
>>> # that worked...
>>> arcpy.FeatureToLine_management("bisectedPoly","bisectedPolyToLine")
<Result 'C:\\Users\\whitley-wayne\\Documents\\ArcGIS\\Default.gdb\\bisectedPolyToLine'>
>>>
... View more
07-08-2014
03:46 PM
|
0
|
0
|
463
|
POST
|
Although not certain how well this will perform for you, and since you are using ModelBuilder, I suppose the easiest most straightforward way may be to use Add Join with the option to only keep joined rows, then execute a Deleted Features (or Delete Rows) to remove those rows. Without seeing your data, I suppose you have a common field to join by and this is essentially how you have been doing it by hand? If you're having problems with the join, particularly with the filtering option to keep only the join rows, there are other options -- for example, leave in the default keep all option on add join, then use Make Feature Layer or Select Layer By Attributes (or even Make Table View) to make the selection for 'is not null' to capture the joined rows before proceeding with your delete rows operation. Wayne
... View more
06-25-2014
04:05 PM
|
0
|
0
|
213
|
POST
|
Sounds like something is turned on that is overriding your attempt to control it yourself... It may be easier to use Maplex anyway-- http://resources.arcgis.com/en/help/main/10.1/index.html#/Introduction_to_the_Maplex_Label_Engine_tutorial/00s800000050000000/
... View more
06-12-2014
02:48 PM
|
0
|
0
|
3770
|
POST
|
Jon, since you said you'll be executing this on quite a few more layers (150+ ?), I'd like to suggest 'combining' your for loops into this one (I didn't test this) in the interest of efficiency (if it works):
for Basin in BasinList:
BasinFeatureClass = arcpy.mapping.Layer(Basin)
arcpy.AddMessage(BasinFeatureClass)
arcpy.mapping.UpdateLayer(df,BasinFeatureClass,PORSymbologyLayer,"TRUE")
arcpy.mapping.AddLayer(df, BasinFeatureClass, "TOP")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
I'm not sure if UpdateLayer output is auto-added to the map; if so, you don't need AddLayer. Also, if you'd like to award Mark something for his contribution, he probably deserves it -- I just came in on this at the tail end... -Wayne PS- Agreed, Mark, ha ha: "Yes, the default is True, but, as it says in the Zen of Python (>>> import this): Explicit is better than implicit." For anyone who hasn't seen the printout of Zen of Python, enter import this at the python command prompt.
... View more
06-06-2014
10:06 AM
|
0
|
0
|
467
|
POST
|
Hello Jon- That's because ListLayers returns a list of Layer objects, so you don't need to try to 'reinstantiate' it as that kind of object - you should be able to do this (provided there's actually a return from ListLayers): BasinLayersInMap = arcpy.mapping.ListLayers(mxd,"*",df) arcpy.AddMessage(BasinLayersInMap) for Basin in BasinLayersInMap: arcpy.mapping.UpdateLayer(df, Basin, PORSymbologyLayer,"TRUE") arcpy.RefreshTOC() arcpy.RefreshActiveView() -Wayne
... View more
06-06-2014
08:09 AM
|
0
|
0
|
467
|
POST
|
I appreciate the fact you are a grad student and searching for answers; I'll be listening for any further response ESRI may have. Meanwhile you may appreciate this little trick...briefly demonstrated below-- Consider that you seem to have in your current session a one-time live reference by the name of your layer in the map, for example, I use "erase". By using 'getOutput(0)' I can essentially get a 'handle' on the layer for later reference...note also (as shown) this result object is of the Layer class.
>>> lyr = arcpy.MakeFeatureLayer_management("erase", "test").getOutput(0)
>>> type(lyr)
<class 'arcpy._mapping.Layer'>
...so if I were to do something like the below, using that handle datasource, I can produce multiple feature layer outputs at will:
>>> myLayerHandles = ['lyr1','lyr2','lyr3','lyr4','lyr5']
>>> for i in range(len(myLayerHandles)):
... arcpy.MakeFeatureLayer_management(lyr.dataSource, myLayerHandles)
...
>>>
To drive this home, if I were to 'get' those layers from my simple map, I could do the below -- note that I'm retrieving the layers I just loaded (and the original "erase" layer along with the 1st MFL execution output layer, "test"). Also note that they are all the equivalent type as the retrieved result object from the MFL getoutput execution above.
>>> currentMXD = arcpy.mapping.MapDocument('current')
>>> layersInCurrentMap = arcpy.mapping.ListLayers(currentMXD)
>>> for i in range(len(layersInCurrentMap)):
... print layersInCurrentMap.name, type(layersInCurrentMap)
...
lyr5 <class 'arcpy._mapping.Layer'>
lyr4 <class 'arcpy._mapping.Layer'>
lyr3 <class 'arcpy._mapping.Layer'>
lyr2 <class 'arcpy._mapping.Layer'>
lyr1 <class 'arcpy._mapping.Layer'>
test <class 'arcpy._mapping.Layer'>
erase <class 'arcpy._mapping.Layer'>
>>>
Admittedly not all of the ESRI documentation is as polished as it should be; however, the above very interesting 'behavior' is documented here: Result (arcpy) Desktop » Geoprocessing » ArcPy » ArcPy classes http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000046000000
... View more
06-05-2014
01:18 PM
|
0
|
0
|
184
|
POST
|
Not sure that I can explain to your complete satisfaction, particularly since I'm not a systems level programmer. I'll try though, and as I said, it is at least related to what you've already surmised is a 'locking' issue, could even be a bug, just not sure -- I just cannot describe where or why exactly the lock is occurring. But to at least entertain that this could be a 'design feature', I'll defend that in saying it could very well serve good purpose in stopping the overwrite or otherwise unintended modification of a map layer. I experimented further with the map layers and there is some in-memory locking and such going on -- I don't think I'll post it here, seems it would only serve at this point to confuse matters. I will say the behavior was consistent on specifying a string that matched a layer name in the TOC executed fine on a '1st iteration'. Not sure if a temporary in-memory reference was made to the the layer in the map, then couldn't 'find' that reference (or clear it for availability) on a '2nd iteration' or what's going on. But I think the overriding principle here is that you can rely on the 'hard-coded' pathname reference to your gdb or possibly even make a specific in-memory copy you can reference again...I wouldn't think it necessary to make an in-memory copy if a perfectly good copy is in a highly available gdb, but then again it depends on how processing intensive you have to get in the steps to reach your final output. Enough said about that I suppose -- I think from here it is worth mentioning there are some very useful arcpy.mapping module techniques you can use to manipulate and refresh the layers in your map after you've finished processing stuff in-memory (or in the default gdb, or python data structure, whatever you have convenient to you). Incidentally, to clarify a statement you said about env.workspace -- I have in my code 3 env statements together. The workspace environment variable did not have to be set there, just a matter of preference, but I just like to keep them together (so they're easy to find and change as needed). Since I set the pathname to the workspace there (env.workspace), then I could make certain I'm specifying the pathname to my layer's datasource itself using os.path.join(<the gdb>, <the fc by name in the gdb>), so that 1st param is simply env.workspace.... and like I said, if you wanted to change that gdb source, you'd only need to change it in one place, where you set the env.workspace var earlier in the script. One more note and I'll close -- the fooling around I did with the layer names wasn't necessary, the layers added to the map did not pass the text, "TVA_Distributors_Layer" or "TVA_PSA_Zips_Layer", because in the loop I wasn't referencing the variables outlayer1 and outlayer2, but the text 'outlayer1' and 'outlayer2' and so that text became the layer names. A better way to pull this off is to use the name property of the layer object in the mapping module, see this: Layer (arcpy.mapping) Desktop » Geoprocessing » ArcPy » Mapping module http://resources.arcgis.com/en/help/main/10.2/index.html#//00s300000008000000 Hope that helps. Wayne
... View more
06-05-2014
10:12 AM
|
0
|
0
|
1422
|
POST
|
@ Ian, I think I solved your gdb quandary...please see your other thread....hope I explained to your satisfaction. To clarify here, the issue is not the same, although you may argue it could be somewhat related. The issue here raised is 'invalid input' (000368)....and your issues raised are 'invalid parameters' and 'in_features, parameter cannot be set' (000622 and 000628) - I think one tripped the other. Oh, by the way, I made an error in the earlier script anyway - and I think your suspicions were well-founded about the lock...I'm still not fully satisfied I understand it, but the workaround is sound. http://forums.arcgis.com/threads/111220-Error-on-Make-Feature-Layer-for-looping-over-selected-attributes#8 Wayne
... View more
05-30-2014
02:56 PM
|
0
|
0
|
377
|
Title | Kudos | Posted |
---|---|---|
1 | 01-09-2013 07:16 AM | |
1 | 12-09-2013 08:44 AM | |
1 | 11-21-2013 07:35 AM | |
1 | 10-31-2012 08:28 AM | |
1 | 12-06-2012 07:44 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|