<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ModelBuilder how to compare several fields between 2 FCs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118000#M9263</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And what should be the output of the tool? A list of differences of a selecting of features?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What if a feature geometry or an attribute that is not being considered in the validation, has been changed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Feb 2016 01:09:57 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2016-02-26T01:09:57Z</dc:date>
    <item>
      <title>ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117997#M9260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to check if features from one FC match features from another feature class. For this purpose I need to compare 3 fields from the first FC to 3 fields from the second FC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I compare 2 feature classes using more than one field? With one field I can use join a join. Is is possible to join several fields between 2 FCS?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do I need to do this compare in python or vb.net?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Feb 2016 23:39:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117997#M9260</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-02-25T23:39:27Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117998#M9261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Probably the easiest way to do this is using Python. You mention ModelBuilder. You can create a tool with Python and add it to ModelBuilder. What do you want to do with the matching features?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 00:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117998#M9261</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-02-26T00:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117999#M9262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am comparing two different days of the same feature class and I am looking for unmatched features to find records inserted and deleted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 00:15:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/117999#M9262</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-02-26T00:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118000#M9263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And what should be the output of the tool? A list of differences of a selecting of features?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What if a feature geometry or an attribute that is not being considered in the validation, has been changed?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 01:09:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118000#M9263</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-02-26T01:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118001#M9264</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good questions!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you help me with an answer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 01:47:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118001#M9264</guid>
      <dc:creator>JoseSanchez</dc:creator>
      <dc:date>2016-02-26T01:47:13Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118002#M9265</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If &lt;EM&gt;Python&lt;/EM&gt; is not your thing, another possible approach would be to use the &lt;EM&gt;Feature Compare&lt;/EM&gt; tool&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/feature-compare.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/feature-compare.htm"&gt;Feature Compare—Help | ArcGIS for Desktop&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris Donohue, GISP&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 01:56:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118002#M9265</guid>
      <dc:creator>ChrisDonohue__GISP</dc:creator>
      <dc:date>2016-02-26T01:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118003#M9266</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To help you a bit,&amp;nbsp; have a look at the tool and code below:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/187880_pastedImage_19.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;Parameters:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;0: FeatureLayer (1)&lt;/LI&gt;&lt;LI&gt;1: Field (multivalue, derived from featurelayer1)&lt;/LI&gt;&lt;LI&gt;2: Featurelayer (2)&lt;/LI&gt;&lt;LI&gt;3: String (direction output) additions&lt;/LI&gt;&lt;LI&gt;4: String (direction output) deletes&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What you choose to do with the resulting lists defines how they should be defined and formatted as output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/187881_pastedImage_21.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy

&amp;nbsp;&amp;nbsp;&amp;nbsp; fc1 = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; selected_flds = arcpy.GetParameterAsText(1)

&amp;nbsp;&amp;nbsp;&amp;nbsp; fc2 = arcpy.GetParameterAsText(2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = selected_flds.split(';')

&amp;nbsp;&amp;nbsp;&amp;nbsp; # check if selected fields in fc2
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Check if selected fields in fc2')
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fld in flds:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(arcpy.ListFields(fc2, fld)) == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError('ERROR: Field {0} not in {1}'.format(fld, fc2))

&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_oid1 = arcpy.Describe(fc1).OIDFieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; fld_oid2 = arcpy.Describe(fc2).OIDFieldName

&amp;nbsp;&amp;nbsp;&amp;nbsp; flds1 = [fld_oid1] + flds
&amp;nbsp;&amp;nbsp;&amp;nbsp; flds2 = [fld_oid2] + flds

&amp;nbsp;&amp;nbsp;&amp;nbsp; # validation: are the three fields combined unique?
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Validation: are the three fields combined unique?')
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not isUnique(fc1, flds1):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("The combination of the 3 field for FC1 is not unique")
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not isUnique(fc2, flds2):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("The combination of the 3 field for FC2 is not unique")

&amp;nbsp;&amp;nbsp;&amp;nbsp; # create dictionary
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Create dictionaries')
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct1 = generateDict(fc1, flds1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct2 = generateDict(fc2, flds2)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # create sets
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Create sets')
&amp;nbsp;&amp;nbsp;&amp;nbsp; set1 = set(dct1.keys())
&amp;nbsp;&amp;nbsp;&amp;nbsp; set2 = set(dct2.keys())

&amp;nbsp;&amp;nbsp;&amp;nbsp; # check additions (in FC2, but not in FC1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Check additions (in FC2, but not in FC1)')
&amp;nbsp;&amp;nbsp;&amp;nbsp; adds = [dct2&lt;A&gt; for a in list(set2 - set1)]&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(adds) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('OIDs added: {0}'.format(adds))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(3, adds)

&amp;nbsp;&amp;nbsp;&amp;nbsp; # check deletes (in FC1, but not in FC2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Check deletes (in FC1, but not in FC2)')
&amp;nbsp;&amp;nbsp;&amp;nbsp; dels = [dct1&lt;A&gt; for a in list(set1 - set2)]&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if len(dels) &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('OIDs deleted: {0}'.format(dels))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(4, list(dels))

def generateDict(fc, flds):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return {u'{0}#{1}#{2}'.format(r[1], r[2], r[3]): r[0] for r in arcpy.da.SearchCursor(fc, (flds))}

def isUnique(fc, flds):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst1 = [u'{0}#{1}#{2}'.format(r[1], r[2], r[3]) for r in arcpy.da.SearchCursor(fc, (flds))]
&amp;nbsp;&amp;nbsp;&amp;nbsp; return len(lst1) == len(list(set(lst1)))

if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:55:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118003#M9266</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T06:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: ModelBuilder how to compare several fields between 2 FCs</title>
      <link>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118004#M9267</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Very true, with the advantage that it will compare all the fields, BUT if the order of the featureclass is changed, it will not be able to detect the changes correctly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Feb 2016 02:08:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/modelbuilder-how-to-compare-several-fields-between/m-p/118004#M9267</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2016-02-26T02:08:45Z</dc:date>
    </item>
  </channel>
</rss>

