Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- This script deletes identical rows in the mls point file.
- Currently tested with 'apn' column which seemingly corresponds to unique listings.
- The column 'apn' was chosen because it provided both a handle on unique mls listing
- while also being a integer field making sorting easy. Sorting was necessary to identify duplicates
- Additionally, many of the duplicate records contained reference to the same parcel but were found 7-10 meters apart.
- This made the 'Delete Identical' tool (ArcGIS Advanced License and up ) inadequate here.
- Once duplicates were removed, the MLS layer could be efficiently loaded in ArcMap.
- '''
- import arcpy
- import time
- workspace = arcpy.env.workspace = r'C:\Users\noah\Desktop\gundog\chandler\data.gdb'
- # city variable
- city = 'chandler'
- def deleteDuplicates():
- fc = 'mls'
- fields = ['apn']
- counter = 0
- matchCount = 0
- sql_clause = (None, 'ORDER BY apn ASC')
- with arcpy.da.UpdateCursor(fc,'apn','','','', sql_clause) as cursor:
- for row in cursor:
- n = row[0]
- if counter > 0 and oldN == n:
- expression = "\"apn\" = {0}" .format(n)
- if expression:
- #print 'We have a match!'
- cursor.deleteRow()
- matchCount = matchCount + 1
- oldN = n
- counter = counter + 1
- print matchCount
- deleteDuplicates()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement