POST
|
Thanks for the reply... To answer your questions: has the data changed - The LRS/Route/Centerline No version - No - -the version currently in production is about 2 years old and unchanged. does it participate in a relationship class - No. The only real change to our production environment are the windows system updates...(Which I believe is the trigger for the exception...which one I don't know) This program is real old and the do events and the GC.Collect, at time, was necessary because of "out of memory errors" on client machines. By "sprinkling them in" -those old errors went away. I will try and remove the GC collection to see if the "Not in collection" exceptions go away... worth a shot. I would rather not start an edit session if I do not have to.... the performance within an edit session is horrible -- it is very very very significantly faster outside. Some large datasets can two days to process inside an edit session whereas only hours outside. So I am treating the edit session as a temporary work around for now. I will report back when I compile the changes... Thanks for your reply!
... View more
03-06-2015
09:20 AM
|
0
|
0
|
460
|
POST
|
I believe Owain Catton mentioned that you are trying to append ".shp" to the name which is invalid for a geodatabase. .shp is reserved for Shape files.... So there may be a question on whether or not you are using Geodatabase layers or layers derived from shape files?
... View more
03-05-2015
08:07 AM
|
0
|
0
|
119
|
POST
|
A custom extension, that has existed many years, stable,.. all of a sudden started get weird errors. Basically this extension takes a point snaps it to a corresponding LRS and retrieves an Offset, Measure, Side, and a segment ID from the Centerline. The last time this extension was re-compiled was around ArcGIS 10.0. I am currently running ArcGIS 10.2.2, the extension was performing fine .... the last successful run was month ago (Not something we run all the time). No changes have been made to ArcGIS system. The Window 7 system has only undergone bi weekly updates send out by microsoft. When I run the extension, I get two pop ups: "Item not found in this Collection" after clearing the above pop-up... "Objects in this Class cannot be updated outside an edit session" The temporary work around is now run the extension after manually setting up an edit session .... No edit session was ever required previously, last 7-8 years of use! The exception is triggered on the pFeat.Store() execution. "results" is a simple Collection . The result collections contains all the correct information...pFeat is defined as an IFeature. I suspect it has something to do with the Window system....Has anyone else experienced this? Any fixes? 'Return a cursor for all the features
pCur = pFlayer.Search(Nothing, False)
pFeat = pCur.NextFeature
Do Until pFeat Is Nothing
System.Windows.Forms.Application.DoEvents()
Route = pFeat.Value(pFeat.Fields.FindField(fPointRouteName))
'Get point to pass
mypoint = pFeat.Shape
Dim results As New Collection
GC.Collect()
System.Windows.Forms.Application.DoEvents()
My.ArcMap.Application.StatusBar.StepProgressBar()
results = getms(Route, mypoint)
Try
'Update fields
If results.Item("SegID") = -9999 Then
results.Remove("ErrDesc")
results.Add("No Centerline SegID Found", "ErrDesc")
End If
pFeat.Value(pFeat.Fields.FindField("MP")) = results.Item("MS")
pFeat.Value(pFeat.Fields.FindField("Offset")) = results.Item("OFFSET")
pFeat.Value(pFeat.Fields.FindField("rSide")) = results.Item("rSide")
pFeat.Value(pFeat.Fields.FindField("ErrDesc")) = results.Item("ErrDesc")
pFeat.Value(pFeat.Fields.FindField("SegID")) = results.Item("SegID")
pFeat.Store()
Catch exp As Exception
MsgBox(exp.Message)
End Try
pFeat = pCur.NextFeature
Loop
... View more
03-04-2015
11:57 AM
|
0
|
6
|
4072
|
POST
|
It is hard to tell from your description what your problem is? If you would attach some sample code where you are having the problem; someone would be able to assist you better.
... View more
03-04-2015
07:21 AM
|
0
|
0
|
501
|
POST
|
I just gave an approach based upon your code to get you unstuck.... I figured the experts would provide the "best practice" alternatives, which greatly helps coding development providing you understand the solution. I did enjoy the finesse displayed at the numerous ways the problem was attacked. You hit upon my gripe with python -- does not work consistently between machines. The code I sent works on mine. I have used other code that works for another person but does not work in my environment. At least with VB it was getting the correct reference then the code worked on any machine. I do not have a lot of confidence stating the code will work for just because it works on my machine. So I enjoy lots of different ways of attacking the problem (give greater chance that one solution will work for me!)
... View more
02-17-2015
07:44 AM
|
0
|
0
|
1189
|
POST
|
I am a VB programmer,not a Python guru. The changes I made are untested.... but doing something along the lines of the changes below should accomplish what you want .... without having to completely re-write the code: (numPoly) is the number of randomly selected Polygons you wish between 1 and something less than the total # of possible polygons there are to select from. # Given an input layer, return an output *.lyr layer file containing a random
# selection of features.
#
# Original author: Leah Saunders, ESRI Inc, on Arcscripts.com. July 2007
# Major modification by Stephen Lead, 21st Feb 2008
import os, sys, random, arcgisscripting
try:
gp = arcgisscripting.create()
gp.overwriteoutput = 1
# Specify input featureclass, output *.lyr file and the percentage of
# random points to return. Set these parameters in ArcToolbox as shown.
inputFC = sys.argv[1] # Feature Class or Feature Layer
outputLyr = sys.argv[2] # Layer File
#inpct = sys.argv[3] # Long
numPoly = sys.argv[3] #Long Must be less than Actual Number of Polygons
# Ensure that the input percentage is between 1 and 100%
#inpct = min(int(inpct),100)
#inpct = max(int(inpct),1)
# Work out how many features to select
inputDirname = os.path.dirname(inputFC)
inputBasename = os.path.basename(inputFC)
gp.workspace = inputDirname
desc = gp.describe(inputFC)
totpnts = gp.getcount(inputFC)
#numValues = int(round(totpnts * float(inpct) / 100.0))
numValues = numPoly
gp.addmessage("Selecting " + str(numValues) + " random features")
# Generate a list of all features, and select randomly from this
inList = []
randomList = []
fldname = desc.OIDFieldName
rows = gp.SearchCursor(inputFC)
row = rows.next()
gp.addmessage ("Loading all IDs into a list")
while row:
id = row.GetValue(fldname)
inList.append(id)
row = rows.next()
selpnts = 0
gp.addmessage("Creating the list of randomly selected features")
while len(randomList) < numValues:
selpnts += 1
selItem = random.choice(inList)
randomList.append(selItem)
inList.remove(selItem)
# Select features whose OID value occurs in the random list, generate
# a *.lyr file from this selection. (Leading and trailing [ and ] marks
# need to be removed from the list object)
theLen = len(str(randomList))
sqlexp = '"' + fldname + '"' + " in " + "(" + str(randomList)[1:theLen - 1] + ")"
selectionLyr = inputBasename + " selection"
gp.MakeFeatureLayer_management(inputFC, selectionLyr, sqlexp)
gp.SaveToLayerFile_management(selectionLyr, outputLyr)
gp.addmessage("\nOutput layer " + outputLyr + " contains features randomly selected from " + inputBasename + "\n")
except:
gp.adderror("Error running script. Try specifying the full path to the input layer")
# END OF FILE
... View more
02-13-2015
12:33 PM
|
1
|
5
|
1189
|
POST
|
Thanks for your help. I still wonder why the script worked on your system/set and not mine -- it appears that we are running the same versions. I am still keeping your script for future investigation/testing --- It is well written! Ted
... View more
02-11-2015
07:41 AM
|
0
|
0
|
409
|
POST
|
Your logic look good! If you are sure that your Catagoria is numeric not null ect..... Then have tried another logical method such as : def FindLabel ( [CATEGORIA],[NUM_CATASTRO], [PARCEL_SP] ):
if [CATEGORIA] > 0:
return [PARCEL_SP]
else:
return [NUM_CATASTRO] ?
... View more
02-10-2015
12:58 PM
|
0
|
0
|
982
|
POST
|
Another note.... The script even honors the db link to another database where the real resides... go figure I would have sworn the script choke on that!
... View more
02-10-2015
12:25 PM
|
0
|
0
|
409
|
POST
|
BTW -- I am on 10.2.2 Don't know why the script did not work. I ran it in idle using the same DB I sent you, I even went as far as creating the same temp locations.... Still the same error. Re-created the Geodatabase ... with OID's (Esri recognized!) Still the same error. Harolds tool -- the MS Access is a personal geodatabase -- however the sign panels are a link to another base pure data. But the test I am doing for automation, it is not a link but a real table with OID's..... This project was to try and acomplish 100% automation for creating a field datase for GIS collection. The techs that would run it have little to no DB/GIS experience -- basically Facebooker's ! I am not a lover of Python because of the reasons I am experiencing -- very temperamental and inconsistant compared to VBA or VB.Net --- there I could trap problems/ repeat them etc.... Seems like I am taking a sledge hammer to perform a very basic sql query .... in any event I got another methodology to work using Select LayerByAttribute_management and building the select clause. I still would be interested in figuring out why both Blake and Bruce script/tool was failing (for competeness sake!) The Script I got to work in my model and my ESRI setup : import arcpy, os
# Local Variables
OriginTable = arcpy.GetParameterAsText(0) #Sign Support --> Make Table View
DestinationTable = arcpy.GetParameterAsText(1) #Sign Panels ---> Make Table View
PrimaryKeyField = arcpy.GetParameterAsText(2) #SupportID /Sign Support
ForiegnKeyField = arcpy.GetParameterAsText(3) #SupportID /Sign Panels
def buildWhereClauseFromList(OriginTable, PrimaryKeyField, valueList):
"""Takes a list of values and constructs a SQL WHERE
clause to select those values within a given PrimaryKeyField
and OriginTable."""
fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(OriginTable).path, PrimaryKeyField)
# Determine field type
fieldType = arcpy.ListFields(OriginTable, PrimaryKeyField)[0].type
# Add DBMS-specific field delimiters
# Add single-quotes for string field values
if str(fieldType) == 'String':
valueList = ["'%s'" % value for value in valueList]
# Format WHERE clause in the form of an IN statement
whereClause = "%s IN(%s)" % (fieldDelimited, ', '.join(map(str, valueList)))
arcpy.AddMessage(whereClause)
return whereClause
def selectRelatedRecords(OriginTable, DestinationTable, PrimaryKeyField, ForiegnKeyField):
"""Defines the record selection from the record selection of the OriginTable
and apply it to the DestinationTable using a SQL WHERE clause built
in the previous definition"""
# Set the SearchCursor to look through the selection of the OriginTable
sourceIDs = set([row[0] for row in arcpy.da.SearchCursor(OriginTable, PrimaryKeyField)])
# Establishes the where clause used to select records from DestinationTable
whereClause = buildWhereClauseFromList(DestinationTable, ForiegnKeyField, sourceIDs)
# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(DestinationTable, "NEW_SELECTION", whereClause)
# Process: Select related records between OriginTable and DestinationTable
selectRelatedRecords(OriginTable, DestinationTable, PrimaryKeyField, ForiegnKeyField) #output same as Destination Table
... View more
02-10-2015
12:15 PM
|
0
|
3
|
409
|
POST
|
Same error even using the dummy up make table query. I even tried a perpared mdb with all the tables having an OID. Same error!
... View more
02-10-2015
10:28 AM
|
0
|
1
|
409
|
POST
|
I have 10.2 .... The panels table has OID's in the version I sent -- used the create table to populate it In the "Real" table that oid field does not exists
... View more
02-10-2015
10:17 AM
|
0
|
1
|
504
|
POST
|
Tool gives me an error on the input layer or table view parameter ... file:///C:/Users/tkowal/AppData/Roaming/ESRI/Desktop10.2/ArcToolbox/Dlg/MdDlgContent.htm#ERROR file:///C:/Users/tkowal/AppData/Roaming/ESRI/Desktop10.2/ArcToolbox/Dlg/MdDlgContent.htm# updateMessage Execution Error: Runtime error Traceback (most recent call last): File "D:\Workspace\MaintUpdate\ProjGIS\KeyfileSelection.tbx#KeyfileSelection.UpdateMessages.py", line 4, in File "D:\Workspace\MaintUpdate\ProjGIS\KeyfileSelection.tbx#KeyfileSelection.UpdateMessages.py", line 31, in updateMessages AttributeError: DescribeData: Method fidset does not exist The panels table does not have an OID or FID; this is not a GIS table but a regular run of the mill tabular table in a database with its own Primary Key other than an OID that ESRI insists upon. Too many other processes use this table to change its structure.
... View more
02-10-2015
09:27 AM
|
0
|
3
|
409
|
POST
|
Selecting WHERE SupportID IN(1001568, 1001498, 1001572, 1001584, 1001573, 1001575, 1001576, 1001574, 1001577, 1001579, 1001578, 1001580, 2001615, 1001585, 1001586, 2002193, 2002278, 2002215, 2002214, 2002194, 1001850, 1001861, 1001855, 1001854, 2001616, 1001860, 1001859, 1001824, 1001853, 1001848, 1001847, 1001849, 1001845, 1001846, 1001843, 1001844, 1001821, 2001715, 2001780, 2001781, 2001804, 2001979, 2001980, 2001981, 2002082, 2001923, 2001924, 2001925, 2001927, 2001948, 2001949, 2001950, 2002225, 2002280, 2002224, 2002282, 2002223, 2002222, 2002221, 2002290, 2002191, 2002293, 2002289, 2002220, 2002219, 2002192, 2002286, 2002218, 2002285, 1001603, 2001867, 1001613, 2002345, 1001618, 2001872, 1001622, 2002346, 1001630, 2002347, 2002348, 2002349, 1001636, 2002350, 2002511, 2002510, 2002549, 2002548, 2002577, 2002523, 2002517, 2002486, 2002547, 2002885, 2002906, 2002907, 2002913, 2002914, 2002915, 2002916, 2002917, 2002964, 2002918, 2002953, 2002954, 2002955, 2002975, 2003054, 2003053, 2003290, 2003406, 2003414, 2003422, 2003427) Inserting rows into template table... Too few parameters. Expected 1. Done
... View more
02-10-2015
08:38 AM
|
0
|
3
|
504
|
Title | Kudos | Posted |
---|---|---|
1 | 10-18-2018 09:46 AM | |
1 | 05-23-2018 08:30 AM | |
8 | 04-18-2019 07:15 AM | |
1 | 02-23-2018 10:08 AM | |
1 | 12-28-2017 07:36 AM |
Online Status |
Offline
|
Date Last Visited |
10-18-2023
06:40 PM
|