I have downloaded the tool "ChangeDetector." by Bruce Harold for ArcGIS. I´m using arcGIS 10.2. Unfortunately I´m getting all the time some errors:

<'type 'exceptions:unicodeError'> ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)

by choosing shape as the only search field I´m getting the following error:

<'type 'exceptions:Runtime:Error'>: Object: CreateObject cannot create geometry from Inputs.

  • 1
    If it is the tool I have used (please provide a link to it), it can't handle other characters than a-z. If you have any ä, é or other non-English characters in file name, field name or text data in your attribute table, it wont work. – Martin Jun 4 '14 at 9:09
  • Here is the link to the Tool. – diesher Jun 4 '14 at 9:16

The tool you have downloaded is very useful, I myself have used it several times. However, it cannot handle non-English characters like ä, ö, é, ü etc. These characters can't be in the file name, field names, or in your data. The unicode character for xf6 in your error message above corresponds to ö, so it is likely that this is your problem.

I have created a code to replace those characters which usually appears in my data, in order for me to be able to use Change detector. It aint all that pretty, but it gets the work done. I have set it up as a script tool with Input shapefile as first parameter, and the field to which you want to do changes as second input. It applies changes to your source data, so make sure you have a backup.

# -*- coding: cp1252 -*-
def code(infield):
    data = ''
    for i in infield:
##        print i
        if i == u'\xc4': #Ä
            data = data + 'AE'
        elif i == u'\xe4': #ä
            data = data + 'ae'
        elif i == u'\xc5': #Å
            data = data + 'AA'
        elif i == u'\xe5': #å
            data = data + 'aa'
        elif i == u'\xd6': #Ö
            data = data + 'OE'
        elif i == u'\xf6': #ö
            data = data + 'oe'
            data = data + i
    return data

shp = arcpy.GetParameterAsText(0)
field = arcpy.GetParameterAsText(1)
##newfield = field + '_U'
##arcpy.AddField_management(shp, newfield, 'TEXT')

prows = arcpy.UpdateCursor(shp)

for row in prows:
    row.field = code(row.getValue(field))

Also keep in mind, the download page states that the function is created for 10.1. I doubt there's been such major changes between 10.1 and 10.2 that it would affect the successful completion of the script, but there's still a chance.

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.