Environment: ArcGIS Desktop 10.6.1
Below, I am attempting to snap a point feature class to the geometry of an address feature class based on a common 'Master ID' field using a join. The code originally comes from arcgis desktop - Snapping point to point based on attribute? - Geographic Information Systems Stack Exchange
However, this is not moving my points, and the data is clean and does match up.
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"D:\\WorkSpace\\POI\\Workspace.gdb\\COH_POI"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"POI_Layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"POI_Layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NEW_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MASTER_ID IS NOT NULL"</SPAN><SPAN class="punctuation token">)</SPAN>
pt_on_line <SPAN class="operator token">=</SPAN> <SPAN class="string token">"D:\\WorkSpace\\POI\\Workspace.gdb\\COH_Address"</SPAN>
pt_on_line_ID <SPAN class="operator token">=</SPAN> <SPAN class="string token">'MasterID'</SPAN> <SPAN class="comment token"># common ID field</SPAN>
pt_off_line <SPAN class="operator token">=</SPAN> <SPAN class="string token">"POI_Layer"</SPAN>
pt_off_line_ID <SPAN class="operator token">=</SPAN> <SPAN class="string token">'MASTER_ID'</SPAN> <SPAN class="comment token"># common ID field</SPAN>
pt_on_line_dict <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">{</SPAN>str<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>pt_on_line<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN>pt_on_line_ID<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">}</SPAN> <SPAN class="comment token"># make dictionary, like {ID:geometry}</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>pt_off_line<SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN>pt_off_line_ID<SPAN class="punctuation token">,</SPAN><SPAN class="string token">"SHAPE@"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># loop through points</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> pt_on_line_dict<SPAN class="punctuation token">[</SPAN>str<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token"># move point geometry to match point geometry from dictionary</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># update the geometry</SPAN>
<SPAN class="keyword token">del</SPAN> cursor<SPAN class="punctuation token">,</SPAN> row<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>