5

I have a string field 'Oneway' with three values '+' '-' and Null showing a street accessibility, I would like to replace them with values 'F' 'T' and null as the script for Network dataset expect these values.However it seems that it is not possible to replace values if Null values are present. I tried also changing the field type to double or text but the field properties are not editable somehow (I tried this in arc catalog). I am only able to replace value '+' and '-' with numbers using the field calculator but need to replace them with letters.

  • 1
    What is the current field type for each of the columns? – Radar Nov 27 '13 at 17:46
  • What is your data format? File geodatabase, shapefile or ArcSDE geodatabase, or ...? – PolyGeo Nov 27 '13 at 22:13
18

An automated way of doing this task is by running a python function within Field Calculator (no selecting and reverse selecting required), see example below:

enter image description here

Additionally, if you want to replace NULL with an empty string just add these two statements:

elif value is None:
    return ''
  • 1
    A superior method! – Hornbydd Nov 27 '13 at 19:35
  • 2
    +1 but it may be worth noting (if I am correct) that returning '' if the data format is a shapefile will actually insert ' '. – PolyGeo Nov 27 '13 at 22:14
6

Here is how I would do this:

  1. Select all rows where oneway = "+" then run a field calculate to set them to "F"
  2. Select all rows where oneway = "-" then run a field calculate to set them to "T"
  3. Select all rows where oneway = "F" AND oneway = "T", reverse the selection then run the field calculate and set remaining rows to "null".
  • 1
    I would say select all rows where oneway = "F" OR oneway = "T". I don't think you have a row where oneway is "F" AND "T". – Techie_Gus Jan 27 '17 at 9:10
0

I had this problem after having done a spatial join - I had null value which in my case needed to changed to 0. I solved it using the following method:

  • Toolbox 'Table Select' (This extracts all the Fields to a table)

  • Toolbox 'Table to Excel'

  • I then opened the resulting Excel file in Excel and using Replace, replaced [Blank] with 0. You then need to format the cells, cell with numbers in them need to be formatted as numbers and text as text etc.

  • Toolbox 'Excel to Table' (All the null values are now 0).

  • Join by attributes to the original feature.

It all worked very well! (Sometimes it is much easier to do things in other programs!)

0
  • Select by attribute for '+'
  • Start editor
  • Click attributes on the editor toolbar
  • Change '+' to 'F' for the selected records in the the field
  • Repeat for '-' to 'T'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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