Need help creating a python script to loop through my data and join/relate points and polygons.

338
1
04-28-2019 04:45 PM
AllisonKelly
New Contributor

I'm having a hard time writing a python script that would allow me to loop through my data and link data from one attribute table to another.  My goal is to get information from property tax roll data point data (ex: number of units, property area) to be included in the parcel polygon records.  I am working with parcel data (polygons) and property tax roll data (points). 

   -  For every parcel there are multiple polygons which are intended to represent the different lots in each parcel.       (442,960 records)

   - The property tax roll data includes multiple points per parcel/lot because the data includes records ranging over       many years. (1,048,575 records)

I want to link information from ONE point to each corresponding polygon.  I want to select one point per "Parcel Number" by the most recent year.  Should I attempt to reduce the point data first; getting the single record per "Parcel Number" before linking the point and polygon data?  Please look at the image below to get a sense of what I am trying to do.  Any help would be greatly appreciated!!! Thank you!

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

Allison,

I think you may not need a spatial join or a Python loop here, I suggest you try the Summary Statistics tool, asking for the MAXIMUM CLOSED_ROLL_YEAR and using parcel ID as the case field. This will give you a table unique by parcel ID (unless I'm not understanding your data, you should check!). 

When you have that table created and have verified it is unique by PARCEL_ID, (there's a Find Identical tool that can help with this), first add an attribute index to your stats table by PARCEL_ID.  Then,

add a join to a the point layer linking to the output table from Summary Statistics using PARCEL_ID as the key field. Then, you can select for assessor_tax_roll_xy.CLOSED_ROLL_YEAR = stat_table.MAX_CLOSED_ROLL_YEAR. This selected set is what you are looking for (I think). 

Once the selection is applied, remove the join and use Copy_Features to copy the selected points to a new output feature class with the points that you want.

Hope this helps.