Setting the Environment in a Script and Joining Tables: What About That?

2816
0
10-03-2014 11:36 AM
RolandShield
New Contributor II

I keep running into the same issues regarding both syntax and code structure and I was hoping someone or some folks might be able and willing to shed light on the issue(s).

 

Situation: In the course of our work, we often, in broad terms, need to do something like the following:

 

1) Create a set of new fc records. And often this is done by grabbing some existing data and updating some of the attiributes.

2) Polulate the attributes of those new records by linking them to other (object) tables and pushing in those values.

 

So, from what I just described above, there are two things that come up, over and over and over.

 

1) I don't work in *an* environment, in my current map. I work in multiple environments---all the time--line by line. So with that, when I see that all of the examples in the "HELP" begin by setting the environment, well, that is NOT helpful, as I am typlically operating against multiple SDE domains all at once, all the time. So, for instance,

ADDRESS = "Database Connections\\SewerViewerREADONLY.sde\\sde_web.GEO.ADDRESS"

PARCEL_table = "Database Connections\\SewerViewerREADONLY.sde\\sde_web.GEO.ADDRESS_PARCEL"

ADDR_WORK = "Database Connections\\GISDEV_EDITOR.sde\\EDITOR.SASD.ADDR_WORK"

 

So as long as I assign a variable to a specific fc from a specific domain in my that is in my current map document up at the top of the script, can I just ignore this explicit environment setting monkey business? And again, I ask because we are constantly working with, for, and against multiple environmenst ALL THE TIME for most of our work. And it would only make sense that others would too. And this because I know we are not the only organization that are continually attempting to maintain current record accuracy between an address db and a parcel db.

 

2) I need to joint an object table to a fc, I then need to access the attribues of those new available attributes after the join is made successfully in my current map document. And so the question arises, what syntax is used in Python and ArcPy to access those attributes?

Is is it simply using a "dot operator" before the joined attribute? Or are no explicit references needed? That is, as long as you spell it right, the code will see it? Or does it want a "forward slash" ? And these are sde fcs turned into variables, mind you. So again, how to access and populate them? And is the syntax the same for both accessing and populating? Or is it different ?

 

3) With the worflow needs of Address FCs (points) and Parcel Tables (or polygon FCs) above, it is rather unclear where and where to use an

AddJoin_management (in_layer_or_view, in_field, join_table, join_field, {join_type}) and when to use an arcpy.JoinField_management (inFeatures, joinField, joinTable, joinField, fieldList). And this confusion is compounded, syntax-wise, when the very next action includes a

with arcpy.da.UpdateCursor(fc, fields) as cursor:

 

I have looked in the "HELP" documentation in ARCGIS Resources, in ArcPy Cafe, and in StackExchange and cannot find any resource that discusses this workflow, that, to me, seems to be a very fundemental essential one.

 

Together, these 3 issues: environment settings, join syntax and construction, and subsequent update(cursor) construction and syntax keep putting up huge hurdles to my development and understanding efforts.

 

Please help! And thanks in advance, y'all

0 Kudos
0 Replies