Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Ive been looking for a solution and unable to find one so please help if able:

I'm trying to avoid manually inputting Begin and End engineering station values already inputted into a seperate field. Thanks for any help on this.

I'm dealing with(4) fields: Begin_Sta, End_Sta, Beg_End and Station. The Begin_Sta and End_Sta fields have engineering stations. The Beg_End field has either "BEGIN" or "END" inputted. The Station field is the one I want to populate using python in the field calculator. If Beg_End has "BEGIN" then the engineering station value in the Begin_Sta field is returned into the Station field, else the End_Sta value is used to populate the Station field. Is this possible using python in the Field Calculator?

share|improve this question
4  
With one of your qualifying fields only having two possible values, you can use a definition query to select half of the records and calculate fields as needed. Then, rinse and repeat with another definition query. Or are you wanting to do something else? –  Baltok Feb 26 '13 at 15:46
    
As far as getting the job done the query is an excellent idea, and I will use it! However, it would be interesting to learn the language to do this in python. Thanks. –  geo_mat Feb 26 '13 at 21:22
    
What format is your data in? What type of GIS software and version is involved? You mention Field Calculator so I am guessing you are using ArcGIS (but what version?). –  PolyGeo Feb 27 '13 at 9:14

1 Answer 1

Yes it is possible, right click your 'Station' field and select Field Calculator. Select python as the parser and check the Show Codeblock box, see screen capture below for code snippet:

enter image description here

share|improve this answer
    
Yes, this PYTHON expression worked very well. Thanks. –  Matthew Feb 28 '13 at 13:18
    
An easier way to write this (in Python without the code block) is simply: !Begin_Sta! if !Beg_End! == 'BEGIN' else !End_Sta! –  Jason Miller Aug 12 at 2:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.