POST
|
I tried a few other things today... though it may be a file locking issue so I copied the template to the local database ... The error message is still the same even in your Try/Exception code This is what the output shows when run Executing (Create Table): CreateTable D:\Workspace\MaintUpdate\ProjGIS\83629_Baseline.mdb pTemplate \\mdxinfo\GIS\BaseData\Signs\MDX_Signs.mdb\SignPanelFieldTemplate # Start Time: Tue Feb 10 10:56:53 2015 Succeeded at Tue Feb 10 10:57:00 2015 (Elapsed Time: 7.48 seconds) Executing (Get Sign Panels for the Selected Supports): GetPanels \\mdxinfo\GIS\BaseData\Signs\MDX_Signs.mdb\SignPanels D:\Workspace\MaintUpdate\ProjGIS\83629_Baseline.mdb\SignSupports D:\Workspace\MaintUpdate\ProjGIS\83629_Baseline.mdb\pTemplate Start Time: Tue Feb 10 10:57:01 2015 Running script GetPanels... Too few parameters. Expected 1. Completed script GetPanels... Succeeded at Tue Feb 10 10:57:06 2015 (Elapsed Time: 5.86 seconds)
... View more
02-10-2015
08:05 AM
|
0
|
5
|
671
|
POST
|
I am using the template. Ran your original code directly from Arcmap same error. Modified the code slightly to run in a model -- same error running arc map 10.2.2 python 2.7.5 The modified model version is: import arcpy
import os
# Local variables modified to work in the model as a script
#fielddb = arcpy.GetParameterAsText(3) #in memory
panels = arcpy.GetParameterAsText (0)
supports = arcpy.GetParameterAsText (1)
template = arcpy.GetParameterAsText (2)
# Get all SupportIDs for where clause IN() statement
supportid = tuple(i[0] for i in arcpy.da.SearchCursor(supports, "SupportID"))
# Optional truncate
# arcpy.TruncateTable_management(template)
# Retreive only panel records that have a support and write to output table
fields = [f.name for f in arcpy.ListFields(template)]
where_clause = "SupportID IN {}".format(supportid)
#arcpy.AddMessage(where_clause)
with arcpy.da.SearchCursor(panels, fields, where_clause) as s_cursor: #too few paramenters. Expected 1
with arcpy.da.InsertCursor(template, fields) as i_cursor:
for row in s_cursor:
i_cursor.insertRow(row)
... View more
02-09-2015
12:01 PM
|
0
|
7
|
671
|
POST
|
My python debugging is not strong in comparison to .net.... but the code bombs out around line 22 RuntimeError: Too few parameters. Expected 1. No clue .. everything appears to be properly coded. I noticed that this error code shows up in regards to an access geodatabase allot of times and the recommendation is to try file geodatase which is not an option for me... I print out the field and the where_clause --- they looked fine?
... View more
02-09-2015
11:07 AM
|
0
|
9
|
671
|
POST
|
That is a lot cleaner code than what I was going to try and do.... I see you were frustrated with the output of the join tools as well (That's what I was fighting!) I will give this a shot and let you know.... I will however have to think about where to develop a template table That was only included for clarification and does not really exist (Yet!) Thanks for your help in this matter --- really appreciated! I will be paying this back forward!
... View more
02-09-2015
08:42 AM
|
0
|
11
|
1373
|
POST
|
The sample dataset contains a table called AllSignPanels small representation my base data describing signs on supports on our system. SignSupports is a FC containing all the Sign Supports in the Project Area. What I am trying to put into the model --- create a table called SignPanels that contains all the sign panels that are on the supports within the Project Area. AllSignPanels.SupportID = SignSupport.SupportID based the SignPanelTemplate. A working query in the database "SelectQueryIwishToModel" creates a view of the table I wish to create. ----------------------- I am also thinking of making a python script tool to construct an "in" statement for the where clause .... thinking about adapting this script: # Local Variables
OriginTable = "This must be a Table View or Feature Layer"
DestinationTable = "This must be a Table View or Feature Layer"
PrimaryKeyField = "Matching Origin Table Field"
ForiegnKeyField = "Matching Destination Table Field"
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."""
# Add DBMS-specific field delimiters
fieldDelimited = arcpy.AddFieldDelimiters(arcpy.Describe(OriginTable).path, PrimaryKeyField)
# Determine field type
fieldType = arcpy.ListFields(OriginTable, PrimaryKeyField)[0].type
# 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)))
return whereClause
def selectRelatedRecords(OriginTable, DestinationTable, PrimaryKeyField, ForiegnKeyField):
"""Defines the record selection from the record selection of the OriginTable
and applys it to the DestinationTable using a SQL WHERE clause built
in the previous defintion"""
# 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)
... View more
02-06-2015
11:13 AM
|
0
|
13
|
1373
|
POST
|
Unfortunately neither works in my case...the Join Fields in order for me to get something close I have to join the many to the one and takes too long and the script adds fields and changes fieldnames with the dataset qualifier to the output in both joins (Fields and Add)... ESRI just does not have any good tabular data tools; unless I wanted a feature class or feature, which I don't. I also ran across in making a feature layer/class in order to get the join to work when converting back to a table view it did not honor the alias name.... the model got too cludgy and messy for such a simple operation. Although the join tool is the solution and does get the proper data it is of a format that is not usable .,.,. it will not work for my Automation project. I am now looking at making (hopefully) a simple python script tool to export the records from the (many) from a unique list of keys. --- I wish they could bring back VBA --- I could have done this in my sleep -- create a recordset -- loop through it and append to a new table. The Dinosaur
... View more
02-06-2015
07:36 AM
|
0
|
15
|
1373
|
POST
|
Here is one methodology to take: In vb.net or C# Make a reference to ADO object (ActiveX Data Object) connect to your database and use the command object to run any functions from your access database. Set up an parameters in code you need to pass.. You will have to set this up as an addin or extension to your mxd. Some references: How to use the ESRI OLE DB provider with a geodatabase Preparing and Executing Commands This is not an easy task Some python possibilities that look promising but you will have to find and install various modules because python does not natively talk with ADO/ActiveX objects Mayukh's World While I was searching I did find this on calling Access from VBScript: Calling function in Access from Vbscript
... View more
02-04-2015
01:49 PM
|
0
|
1
|
1432
|
POST
|
Thinking about that, yes I believe you cannot reference an access object with VBScript... I know you can in VBA but ESRI has terminated that so another way I think you can do it is through Net C# or VB.Net where you can reference the object but you would have to write an addin or extension to do it. My knowledge of python is not adequate to speculate whether or not this could be done -- I know the ODBC api is quite buggy when I played around with that.
... View more
02-04-2015
01:28 PM
|
0
|
0
|
1432
|
POST
|
Does this article help you any ... I have used VBS functions to open Access modules functions, forms etc .. https://community.esri.com/thread/32176#post117532
... View more
02-04-2015
08:03 AM
|
0
|
1
|
1432
|
POST
|
Yes I have been in the trenches of this project too long.... I have had too many interruptions. I did have an Add Join at one time (probably when I was fresher earlier in the undertaking). For some reason I thought the iterator was a little more full fledged and got bogged in that direction... knowing that I could perform a simple query to extract the filtered table at last resort leaving one manual step! Mainly this project was an exercise for me to finally start to learn Python and the Modeling Tools which I have totally ignored up to this point! I was and am determined to at least get one under my belt! Thanks alot for pulling me out of my fog! Ted
... View more
02-04-2015
07:34 AM
|
0
|
0
|
1373
|
POST
|
I am an old VB/VB.Net guy and this one has me stumped in terms of building a tool using model builder so any assistance in leading me to a solution will be greatly appreciated. (I can build a vbs script to this but I am attempting to do this within modelbuilder/python script [if necessary]) Background: I work for a transportation agency. Our GIS field collection is based upon new construction projects. For any project, all of our GIS layers are extracted that fall within a buffered distance of the project along with all the attributes that are associated with the objects. I felt that this would be a great place to use modelbuilder to make a tool that would do this so my tech's that have no SQL experience can quickly create a MS Access Field Geodatabase. Old method was to manually export each layer (a process that could take upwards to a week to complete. I completed 99.9% of the problem within the model and it can create the field database in a matter minutes. However..... I have one small problem. Our traffic signs are stored in the database as two objects: 1. Sign support (GIS point feature class) 2. SignPanels which is an independent tabular table. The linkage between both objects is the SignSupportID which is the primary key in the Sign Support layer and foreign key in the tabular table. Problem: I would like to create/copy tabular table of specified fields from the SignPanels table that have a matching Sign Support ID from the Sign support GIS layer (This is a filtered set containing the sign support points within the project area)... This seems to be a simple common problem but I have hit wall.... Manually, I would simply create an sql statement selecting those SignPanels that were "in" the filtered sign support gis layer table. Select * from SignPanels SP where SP.SupportID in (Select SupportID from SignSupports where Project = "XXXXX") Solution or Methodology needed: .. using Model builder I need a Feature Class and Tabular Table along with a query that can iterate through the FC for all the ID's ...) I already have the Filtered GIS layer as an output in the model. What I now need is to create a table containing my desired attributes of only those panels in the SignPanels table that have a support id that matches the Filtered GIS layer. Confused? Any Ideas? Thanks ahead of time! Ted
... View more
02-03-2015
01:44 PM
|
0
|
28
|
7267
|
POST
|
No problem! We all started new to the GIS Field and received help. My background is not computers or GIS, I am a Structural Engineer -- but I had to learn GIS and Programming.... I receive lots of help from this site from some very smart and intelligent people. So I help others out when and if I can. Thanks for your gracious comments!
... View more
01-28-2015
07:22 AM
|
0
|
0
|
389
|
POST
|
Andreas, I can give you a methodology to get you started. It is not the best, but it uses the tools that come with ArcGIS and no added programming... Looking at your data the only link between your accidents and the road is a coordinate value. Some of these fall greater than 55 meters away from the nearest road so any relationships made between the two datasets will still need to be checked for correctness especially those points that are the greatest distance from you road as well as those close to intersections. Having a road-name or identifier with your accidents would make this process much easier, however as GIS folks we have to work with what we have First of all it is not a good practice to place fields for 15 accidents on your road layer. I removed these fields and copied your road layer to a shape called RoadSeg. The goal is to create a link between your accidents and the road layer and use a join to bring the information together! I will be using the FID or the road layer to make this linkage between the road and accidents (Best practice would be to create your own unique Identifier for your road segments ones that don't change) You cannot guarantee that the FID will not change for a segment. I then exported your accident data to a shape file and added a field called SegID (We will populate this with the FID of the Road Segment). I then used the Toolbox Tool Near Toolbox/Analysis Tool/Proximity/Near Using the Accident points as input and the near RoadSeg with a search radius 60 meter (Much too big accident coordinate may not be accurate). This created two field in the accident shape called Near_FID (RoadSeg FID) and the Near_Dist (the distance away the point was located from the road... Now you have everything you need to join the accidents to the road segments...(you can populate the SegID field of the Accidents with the Near_FID of the roads) Hope this helps getting you going without manually inputting all those accidents!
... View more
01-23-2015
08:31 AM
|
1
|
2
|
389
|
POST
|
As Jake mentioned there are numerous different Geoprocessing tools that will do this depending on your own unique conditions.... Have you tried the most simple direct way? Right click on the field you want to populate on your attribute table and choose calculate geometry?
... View more
01-16-2015
07:17 AM
|
3
|
1
|
7685
|
POST
|
I just saw this post a little late ... but I had to do some cleaning of a text address field from another agency... I ran across a script that would parse many of the US type of addressing using pyparsing -- I do not know where I got the script or to whom to give credit to but I have adapted the script for use in the field calculator and has proven to be an excellent workhorse for me.... You will of course have to adapt it for you own specific use.... the example below parses the streetname from the address..... you can retrieve also the house number, streetnumber, streettype, PO Box etc... from pyparsing import *
def ParseAddress(address):
# define number as a set of words
units = oneOf("Zero One Two Three Four Five Six Seven Eight Nine Ten"
"Eleven Twelve Thirteen Fourteen Fifteen Sixteen Seventeen Eighteen Nineteen",
caseless=True)
tens = oneOf("Ten Twenty Thirty Forty Fourty Fifty Sixty Seventy Eighty Ninety",caseless=True)
hundred = CaselessLiteral("Hundred")
thousand = CaselessLiteral("Thousand")
OPT_DASH = Optional("-")
numberword = ((( units + OPT_DASH + Optional(thousand) + OPT_DASH +
Optional(units + OPT_DASH + hundred) + OPT_DASH +
Optional(tens)) ^ tens )
+ OPT_DASH + Optional(units) )
# number can be any of the forms 123, 21B, 222-A or 23 1/2
housenumber = originalTextFor( numberword | Combine(Word(nums) +
Optional(OPT_DASH + oneOf(list(alphas))+FollowedBy(White()))) +
Optional(OPT_DASH + "1/2")
)
numberSuffix = oneOf("st th nd rd").setName("numberSuffix")
streetnumber = originalTextFor( Word(nums) +
Optional(OPT_DASH + "1/2") +
Optional(numberSuffix) )
# just a basic word of alpha characters, Maple, Main, etc.
name = ~numberSuffix + Word(alphas)
# types of streets - extend as desired
type_ = Combine( MatchFirst(map(Keyword,"ST BLVD LN RD AVE PASS "
"TRL PATH PSGE WAY LANE "
"CIR DR PKWY CT SQ "
"LP TER TERR PL".split())) + Optional(".").suppress())
# street name
nsew = Combine(oneOf("N S E W North South East West NW NE SW SE") + Optional("."))
streetName = (Combine( Optional(nsew) + streetnumber +
Optional("1/2") +
Optional(numberSuffix), joinString=" ", adjacent=False )
^ Combine(~numberSuffix + OneOrMore(~type_ + Combine(Word(alphas) + Optional("."))), joinString=" ", adjacent=False)
^ Combine("Avenue" + Word(alphas), joinString=" ", adjacent=False)).setName("streetName")
# PO Box handling
acronym = lambda s : Regex(r"\.?\s*".join(s)+r"\.?")
poBoxRef = ((acronym("PO") | acronym("APO") | acronym("AFP")) +
Optional(CaselessLiteral("BOX"))) + Word(alphanums)("boxnumber")
# basic street address
streetReference = streetName.setResultsName("name") + Optional(type_).setResultsName("type")
direct = housenumber.setResultsName("number") + streetReference
intersection = ( streetReference.setResultsName("crossStreet") +
( '@' | Keyword("and",caseless=True)) +
streetReference.setResultsName("street") )
streetAddress = ( poBoxRef("street")
^ direct.setResultsName("street")
^ streetReference.setResultsName("street")
^ intersection )
# how to add Apt, Suite, etc.
suiteRef = (
oneOf("Suite Ste Apt Apartment Room Rm #", caseless=True) +
Optional(".") +
Word(alphanums+'-')("suitenumber"))
streetAddress = streetAddress + Optional(Suppress(',') + suiteRef("suite"))
return streetAddress.parseString(address, parseAll=True)
__esri_field_calculator_splitter__
ParseAddress( !PHY_ADDR1!).street.name
... View more
01-13-2015
08:31 AM
|
0
|
0
|
344
|
Title | Kudos | Posted |
---|---|---|
1 | 10-18-2018 09:46 AM | |
1 | 05-23-2018 08:30 AM | |
9 | 04-18-2019 07:15 AM | |
1 | 05-04-2016 08:15 AM | |
1 | 03-24-2017 01:22 PM |
Online Status |
Offline
|
Date Last Visited |
10-18-2023
06:40 PM
|