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.

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.

share|improve this question
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 at 9:09
    
Here is the link to the Tool‌​. –  Geo_Diesher Jun 4 at 9:16

1 Answer 1

up vote 5 down vote accepted

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'
        else:
            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))
    prows.updateRow(row)

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.

share|improve this answer

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.