Select to view content in your preferred language

Compare attributes in two different feature class

02-27-2018 03:55 PM
New Contributor III

I have two polyline feature class in a FGDB , I need to compare field "Field1", "" from both layer  and if it matches i need it to populate field "Verifi" with "Match" or if it doesn't match to populate "Verifi" with "No Match". I do not know how to do in ArcPy.Solution?jayanta.poddar

0 Kudos
4 Replies
MVP Emeritus

In order to compare two fields in two different files, you need to be able to join the tables together on a common key (perhaps an ID field or equivalent)

Add a field to the destination table to put the comparison results.

Once joined, then you can perform an equality check using the field calculator

You indicate that you need to do this with an arcpy solution.  The best way to do that is to examine the code snippets for the basic tools (ie Add Join, Calculate Field etc).  If you have made progress on that front, you might want to include it in your post.

New Contributor III

one more input is schema of both data-sets is same but geometry location is changed.  for example a line segment in version1.FGDB is 5 meter, but same length of line might have  more segments or less. See the picture.

Now I want to compare field values of both feature class and populate the results. I not proficient in ArcPy but I hope it is do able. Need guidance.

Thank you in anticipation.

0 Kudos
Esri Esteemed Contributor

When you mention that a line in the other featureclass might have "more segments", are you referring to that a single feature in one featureclass might correspond to multiple features in the other featuresclass, or that the feature is a multi-part or that the feature has more vertices?

Are you trying to match features in both featureclass to ultimately compare attributes or to compare geometries? Both could be possible, however as Dan already mentioned there has to be an ID field that identifies how features should be matched. If you don't have this, you might be able to use the geometry to match features from both featureclasses (using a Spatial Join) but all depend on your data and specific objectives.

0 Kudos
MVP Honored Contributor

The process you are trying to do is called conflation and the best tool for doing this is the Detect Feature Changes tool in the Data Comparison Toolset of the Data Management Toolbox.  This tool requires an Advanced license and was first available in ArcMap 10.2, so if you have that license and a version of ArcMap that supports it you should definitely use this tool, since there is nothing better.  The tool can compare line feature classes in all the ways you have described and more using tolerance settings that you specify and will compare any matching attributes that you want.  The tool can also create a separate table that shows all OID relationships between the two feature classes with all records needed to show all line to line matches for one-to-one, one-to-many, many-to-one, and many-to-many matches.  Once all relationships are created by the tool you can do standard selections based on the attributes and relates to the table so you can use the field calculator to update your lines to indicate whether or not they are matched.  No tool can do this kind of matching without some false positive and false negative matches, but this tool does everything needed to get the best results that will allow you to validate the results the quickest.