Select to view content in your preferred language

Comparing fields from two Feature Classes.

2522
1
06-06-2014 06:35 AM
DaleShearer
Frequent Contributor
Hi, and thank you for taking your time to look at my post.  I am new to Python(I was in a class at this time a week ago).  I am looking for a Python function(?) to compare a field in two seperate feature classes.  arcpy.SelectLayerByAttribute_management looks close to what I am looking for, but I do not think it will work for my use.  I cannot join the layers.

Here is my scenario.  I have an address feature class and street feature class, the address feature class has a field that is tied to the street the address is located.  So all addresses on Main St. have a StreetID field, the number in the StreetID field should match the ID field of Main St. in the Street feature class.

I want to create a new layer/feature class of the Addresses where the StreetID in Addresses does not match the ID of the street in Streets.

In VB.net I had it looping through the streets, searching the addresses that matched the street name (street, city, state, zip) and then comparing the StreetID - ID fields, writing errors to a selection set then creating the layer.

In my brief experience with arcpy I would think there is a funtion that allow me to do that. 

Not looking for code, just wanting to find out if there is a function I can work with.

Thanks, Dale
Tags (2)
0 Kudos
1 Reply
KimOllivier
Honored Contributor
Why can't you join the layers? It does seem a bit of a lost cause if you can't at least do that.
However some joins may be very inefficient if there is no index and you do not have permission to build it.
Copy the data so that you can, or extract the data to enable the comparision.
Don't think 'loop through' if at all possible, use SQL type queries on whole tables for efficiency.
If the data is small enough to fit into memory there are Python structures to make comparisons fast.
For example you could use a cursor to read in the fields from each table into a list and a dictionary and run a set comparision to get a list of differences. If that is small compared to the total, then there is a huge benefit.
0 Kudos