Hi there.
I have created a script that works as a GPS integrity script for all of our point features. If a user has inadvertently moved a point feature from it's GPS'ed location, than the script will move it back, keeping our accuracy high. In other words, the script calculates the distance between the 'SHAPE@X' and 'SHAPE@Y' fields and our high accuracy GNSS enabled fields "ESRIGNSS_LONGITUDE" and "ESRIGNSS_LATTITUDE".
If the calculated distance (dist_diff) fall outside the bounds of our set tolerance level (toleranceValue) for that particular feature class, then the points are moved back to our GNSS locations via the UpdateCursor. The GNSS lat and lon points are re-projected to our local state plane coordinate system using PyProj.
Then it should be as simple as replacing the SHAPE@X and SHAPE@Y fields that fall outside the toleranceValue with the re-projected lat and lon values, and then writing those features to a new feature class.
However, I keep getting the following error:
Traceback (most recent call last):
File "<input>", line 184, in <module>
RuntimeError: The modified geometry must be a different geometry instance from the feature's original geometry (e.g., a copy or new instance). [class name = CityworksGIS_Test.DBO.wControlValve, object id = 104]
This is puzzling to me, as the first feature class in the list passes through the UpdateCursor with no problems. But then I get this error on the second iteration of the loop, with the wControlValve feature class.
I feel like I could just be overlooking something... If someone could please put their eyes on my code, I'd truly appreciate it, and would gladly return the favor in the future.
Thank you.
Code below:
<SPAN class="comment token"># Import These</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="keyword token">import</SPAN> pyproj <SPAN class="keyword token">as</SPAN> proj
<SPAN class="keyword token">import</SPAN> numpy <SPAN class="keyword token">as</SPAN> np
<SPAN class="keyword token">from</SPAN> geopy <SPAN class="keyword token">import</SPAN> distance
<SPAN class="comment token">### ENIVRONMENT SETUP ###</SPAN>
__author__ <SPAN class="operator token">=</SPAN> <SPAN class="string token">'zemp'</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os<SPAN class="punctuation token">,</SPAN> sys<SPAN class="punctuation token">,</SPAN> subprocess<SPAN class="punctuation token">,</SPAN> time<SPAN class="punctuation token">,</SPAN> csv
<SPAN class="keyword token">from</SPAN> datetime <SPAN class="keyword token">import</SPAN> datetime
<SPAN class="comment token"># Variables</SPAN>
<SPAN class="comment token"># Enterprise Database Connection</SPAN>
EnterpriseDB <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\\Users\\zemp\\AppData\\Roaming\\Esri\\Desktop10.6\\ArcCatalog\\DBO@City_Works_Test.sde"</SPAN>
<SPAN class="comment token"># Import Toolbox</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>ImportToolbox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'M:/ArcGIS/Tools/SkagitPUD.tbx'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'pud'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># The name of the SQL database for script logging with pyodbc</SPAN>
sqldbname <SPAN class="operator token">=</SPAN> <SPAN class="string token">'CityworksGIS'</SPAN>
<SPAN class="comment token"># The name of the SQL Server</SPAN>
sqlservername <SPAN class="operator token">=</SPAN> <SPAN class="string token">'arcgis'</SPAN>
<SPAN class="comment token"># Set workspace</SPAN>
workspace <SPAN class="operator token">=</SPAN> EnterpriseDB
<SPAN class="comment token"># Set the workspace environment</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> workspace
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token"># block new connections to the working and prod database.</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Blocking Connections..."</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AcceptConnections<SPAN class="punctuation token">(</SPAN>EnterpriseDB<SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># disconnect all users from CityworksGIS database.</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"Disconnecting Users..."</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>DisconnectUser<SPAN class="punctuation token">(</SPAN>EnterpriseDB<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ALL"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># -------------------------------------DATA IMPORT------------------------------------------------------------------</SPAN>
<SPAN class="comment token"># Gather all datasets</SPAN>
datasets <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListDatasets<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"Feature"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Gather all tables</SPAN>
tableList <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListTables<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ALL"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Gather all feature classes</SPAN>
fcListDatasets <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">if</SPAN> len<SPAN class="punctuation token">(</SPAN>datasets<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> dataset <SPAN class="keyword token">in</SPAN> datasets<SPAN class="punctuation token">:</SPAN>
fcListDatasets <SPAN class="operator token">+=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<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> dataset<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Get wFCs from water distribution dataset</SPAN>
wIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>datasets<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'Water_Distribution'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
wIndex <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>wIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
fcListWater <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<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> datasets<SPAN class="punctuation token">[</SPAN>wIndex<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Gather FCs from ROOT:</SPAN>
fcListRoot <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>ListFeatureClasses<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="comment token"># Combine Lists</SPAN>
<SPAN class="keyword token">if</SPAN> len<SPAN class="punctuation token">(</SPAN>datasets<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">></SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
fcList <SPAN class="operator token">=</SPAN> fcListDatasets <SPAN class="operator token">+</SPAN> fcListRoot
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
fcList <SPAN class="operator token">=</SPAN> fcListRoot
<SPAN class="comment token"># -------------------------------------FIND INDICES AND FILEPATHS OF DATA------------------------------------------</SPAN>
fcListWaterLength <SPAN class="operator token">=</SPAN> len<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN>
fcListWaterRange <SPAN class="operator token">=</SPAN> range<SPAN class="punctuation token">(</SPAN>fcListWaterLength<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Find index of feature classes within feature class list:</SPAN>
hydrantIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wHydrant'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
meterIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wMeter'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
mainLineIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wMain'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
controlValveIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wControlValve'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
fittingIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i<SPAN class="punctuation token">,</SPAN> s <SPAN class="keyword token">in</SPAN> enumerate<SPAN class="punctuation token">(</SPAN>fcListWater<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wFitting'</SPAN> <SPAN class="keyword token">in</SPAN> s<SPAN class="punctuation token">]</SPAN>
systemValveIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fcListWater <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wSystemValve'</SPAN> <SPAN class="keyword token">in</SPAN> i <SPAN class="operator token">and</SPAN> <SPAN class="string token">'_D'</SPAN> <SPAN class="operator token">not</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN>
casingIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fcList <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'CasingEndpoint_SurveyGrade'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN>
utilityCrossingIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fcList <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'UtilityCrossing_SurveyGrade'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN>
pipeAlignmentIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fcList <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'PipeAlignment_SurveyGrade'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN>
refPointIndex <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>i <SPAN class="keyword token">for</SPAN> i <SPAN class="keyword token">in</SPAN> fcList <SPAN class="keyword token">if</SPAN> <SPAN class="string token">'ReferencePoint_SurveyGrade'</SPAN> <SPAN class="keyword token">in</SPAN> i<SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Pull file paths</SPAN>
wCasing <SPAN class="operator token">=</SPAN> casingIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
wUtilityCrossing <SPAN class="operator token">=</SPAN> utilityCrossingIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
wPipeAlignment <SPAN class="operator token">=</SPAN> pipeAlignmentIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
wRefPoint <SPAN class="operator token">=</SPAN> refPointIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
wSystemValve <SPAN class="operator token">=</SPAN> workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> systemValveIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
wHydrant <SPAN class="operator token">=</SPAN> workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> fcListWater<SPAN class="punctuation token">[</SPAN>hydrantIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN>
wMeter <SPAN class="operator token">=</SPAN> workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> fcListWater<SPAN class="punctuation token">[</SPAN>meterIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN>
wControlValve <SPAN class="operator token">=</SPAN> workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> fcListWater<SPAN class="punctuation token">[</SPAN>controlValveIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN>
wFitting <SPAN class="operator token">=</SPAN> workspace <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\"</SPAN> <SPAN class="operator token">+</SPAN> fcListWater<SPAN class="punctuation token">[</SPAN>fittingIndex<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="comment token"># Combine into list</SPAN>
pointList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>wCasing<SPAN class="punctuation token">,</SPAN> wUtilityCrossing<SPAN class="punctuation token">,</SPAN> wPipeAlignment<SPAN class="punctuation token">,</SPAN> wRefPoint<SPAN class="punctuation token">,</SPAN> wSystemValve<SPAN class="punctuation token">,</SPAN> wHydrant<SPAN class="punctuation token">,</SPAN> wMeter<SPAN class="punctuation token">,</SPAN> wControlValve<SPAN class="punctuation token">,</SPAN>
wFitting<SPAN class="punctuation token">]</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wCasing<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wCasing_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wUtilityCrossing<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wUtilityCrossing_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wPipeAlignment<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wPipeAlignment_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wRefPoint<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wRefPoint_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wSystemValve<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wSystemValve_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wHydrant<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wHydrant_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wMeter<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wMeter_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wControlValve<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wControlValve_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>wFitting<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wFitting_layer"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Combine into list</SPAN>
pointList_layer <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"wCasing_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wUtilityCrossing_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wPipeAlignment_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wRefPoint_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wSystemValve_layer"</SPAN><SPAN class="punctuation token">,</SPAN>
<SPAN class="string token">"wHydrant_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wMeter_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wControlValve_layer"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"wFitting_layer"</SPAN><SPAN class="punctuation token">]</SPAN>
pointList_layer<SPAN class="punctuation token">.</SPAN>sort<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">### METHOD 1: ###</SPAN>
nad83 <SPAN class="operator token">=</SPAN> proj<SPAN class="punctuation token">.</SPAN>Proj<SPAN class="punctuation token">(</SPAN>init<SPAN class="operator token">=</SPAN><SPAN class="string token">'epsg:6318'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># assuming you're using NAD83</SPAN>
wa_sp <SPAN class="operator token">=</SPAN> proj<SPAN class="punctuation token">.</SPAN>Proj<SPAN class="punctuation token">(</SPAN>init<SPAN class="operator token">=</SPAN><SPAN class="string token">'epsg:2285'</SPAN><SPAN class="punctuation token">,</SPAN> preserve_units <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># use a locally appropriate projected CRS</SPAN>
gnssX <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
gnssY <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
shapeX <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
shapeY <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
objectID <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
distDiff <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
totalCount <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
outPath <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">for</SPAN> x <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
flag <SPAN class="operator token">=</SPAN> <SPAN class="string token">"_Flagged"</SPAN>
<SPAN class="comment token"># Path for writing FCs to memory:</SPAN>
memory <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"in_memory/"</SPAN>
tempEnd <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"_temp"</SPAN>
<SPAN class="comment token"># Path for new Feature Dataset</SPAN>
fd <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\\Users\\zemp\\AppData\\Roaming\\Esri\\Desktop10.6\\ArcCatalog\\DBO@City_Works_Test.sde\\GPSIntegrityCheck"</SPAN>
edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> j <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># Get count for each point feature</SPAN>
totalCount<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"now working on"</SPAN><SPAN class="punctuation token">,</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set tolerance Values</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="string token">'wHydrant'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">2.0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"wHydrant"</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'wControlValve'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1.0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"wControlValve"</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'wSystemValve'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0.5</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"wSystemValve"</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'wFitting'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0.5</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'wFitting'</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'wMeter'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">1.0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"wMeter"</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'CasingEndpoint'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'wCasingEndPoint'</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'UtilityCrossing'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'wUtilityCrossing'</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'PipeAlignment'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'wPipeAlignment'</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">elif</SPAN> <SPAN class="string token">'ReferencePoint'</SPAN> <SPAN class="keyword token">in</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
toleranceValue <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
featureName <SPAN class="operator token">=</SPAN> <SPAN class="string token">'wReferencePoint'</SPAN> <SPAN class="operator token">+</SPAN> flag
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">pass</SPAN>
<SPAN class="comment token"># Start search cursor for the following rows</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"The tolerance value is"</SPAN><SPAN class="punctuation token">,</SPAN> toleranceValue<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"for"</SPAN><SPAN class="punctuation token">,</SPAN> pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</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>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SHAPE@X'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SHAPE@Y'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ESRIGNSS_LONGITUDE'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'ESRIGNSS_LATITUDE'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'OBJECTID'</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="keyword token">if</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">is</SPAN> <SPAN class="operator token">not</SPAN> None <SPAN class="operator token">and</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">is</SPAN> <SPAN class="operator token">not</SPAN> None<SPAN class="punctuation token">:</SPAN>
<SPAN class="punctuation token">[</SPAN>lonX<SPAN class="punctuation token">,</SPAN> latY<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> proj<SPAN class="punctuation token">.</SPAN>transform<SPAN class="punctuation token">(</SPAN>wa_sp<SPAN class="punctuation token">,</SPAN> nad83<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> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
GNSS_location <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
GIS_location <SPAN class="operator token">=</SPAN> latY<SPAN class="punctuation token">,</SPAN> lonX
<SPAN class="comment token"># Calculate difference between GIS and GNSS location using NAD83 and GRS Elipsoid</SPAN>
dist_diff <SPAN class="operator token">=</SPAN> distance<SPAN class="punctuation token">.</SPAN>geodesic<SPAN class="punctuation token">(</SPAN>GNSS_location<SPAN class="punctuation token">,</SPAN> GIS_location<SPAN class="punctuation token">,</SPAN> ellipsoid<SPAN class="operator token">=</SPAN><SPAN class="string token">'GRS-80'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>feet
<SPAN class="keyword token">if</SPAN> dist_diff <SPAN class="operator token">>=</SPAN> toleranceValue<SPAN class="punctuation token">:</SPAN> <SPAN class="comment token"># If points is outside tolerance zone, do this:</SPAN>
objectID<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">4</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
gnssX<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>lonX<SPAN class="punctuation token">)</SPAN>
gnssY<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>latY<SPAN class="punctuation token">)</SPAN>
shapeX<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>lonX<SPAN class="punctuation token">)</SPAN>
shapeY<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>latY<SPAN class="punctuation token">)</SPAN>
distDiff<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN>dist_diff<SPAN class="punctuation token">)</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> lonX
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> latY
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">pass</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">pass</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"The total count is: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>totalCount<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> "<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="comment token"># of records outside tolerance: " + str(len(distDiff<J>)))</J></SPAN>
<SPAN class="keyword token">for</SPAN> id <SPAN class="keyword token">in</SPAN> objectID<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">:</SPAN>
stringID <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>id<SPAN class="punctuation token">)</SPAN>
where_clause <SPAN class="operator token">=</SPAN> <SPAN class="string token">"OBJECTID = '"</SPAN> <SPAN class="operator token">+</SPAN> stringID <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"ADD_TO_SELECTION"</SPAN><SPAN class="punctuation token">,</SPAN> where_clause<SPAN class="operator token">=</SPAN>where_clause<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">if</SPAN> j <SPAN class="operator token">!=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">del</SPAN> totalSelected
totalSelected <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
totalSelected <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>arcpy<SPAN class="punctuation token">.</SPAN>GetCount_management<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"New Selection Total: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>totalSelected<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\nSelection from tolerance table: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>objectID<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n Records that were not matched: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>objectID<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">-</SPAN>totalSelected<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n Total Records: "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>totalCount<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><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>
outPath <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>fd<SPAN class="punctuation token">,</SPAN> str<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN><SPAN class="string token">"_GPS_Flagged"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CopyFeatures_management<SPAN class="punctuation token">(</SPAN>pointList_layer<SPAN class="punctuation token">[</SPAN>j<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> outPath<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Stop Editing</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN><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></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><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></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><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></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><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></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><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></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><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></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><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></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><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></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><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>