6

I have a shapefile (.shp) of 180k roads with information of street name.

I need to do a Dissolve on that road network to make only one feature per name.

But I have a problem by doing that task because I have cases that the name differs only by one character.

For example:

Rua do servidor pÚblico & Rua do servidor pUblico

or

Rua do SouZa & Rua do SouSa

I was thinking to do something like select all the attributes that match 99% of the string to find that cases.

I don't know how to do it, maybe a python or VB script will do it. Please, give me a light, and I'll follow it.


I've found something like FUZZY MATCHING...I'll research about it.

2

I would aim at making a mapping between the street names and their object id. I don't know what program you will be using to get into the shapefile, but here is a basic Python script that might help. It will loop through the shapefile and log each name, and the OIDs that match it (given my parameters). You'll probably need to work in more parameters to match them better. Here goes:

def IsCloseMatch(name1,name2):
"""If the number of characters is different, returns False.
   If more than 95% of the characters are different, returns False.
   Otherwise, returns True"""
  if not len(name1) == len(name2):
    return False
  enum1 = enumerate(name1)
  enum2 = enumerate(name2)
  numberofmatches = 0
  for index, char in enum1: # Loop through string character by character
    if enum2[index] == char:
      numberofmatches += 1
  if numberofmatches/len(name1) > .95: # Looking for 95% character match
    return True
  else:
    return False

matches = {} # {name1:[oid1,oid2...], name2:[oid1,oid2...], ...} 

for feature in shapefile:
  if matches.has_key(feature.streetname):
    matches[feature.streetname].append(feature.oid)
  else:
    for name in matches.keys():
      if IsCloseMatch(name,feature.streetname): 
        matches[name].append(feature.oid) # if matches, add oid
      else:
        matches[feature.streetname] = [feature.oid] # if not, add new street name

I haven't added any catches if there are one or two extra letters, but it's a start. What you do after you have the matching street names and the features that need to be dissolved depends on what tools you are using, but maybe this will help

  • Thx @cndnflyr, I'll git a try. – Ycavazin Oct 29 '13 at 16:17
1

I've found a way to do that FUZZY MATCHING task on my street network.

I dunno how to do it on ArcGIS, but I exported my street network to CSV and opened it on Excel.

Then I've used this awesome-free-tool:

Fuzzy Lookup Add-In for Excel

It's easy to use and really do the job.

Thanks to all of you that helped me.

See ya.

Yuri Cavazin

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.