Pythonaddins tool for selecting polygon and export some specific attributes to csv

06-15-2015 09:44 AM
New Contributor

Is there a pythonaddins tool or script with which I can click on a feature class polygon to be selected and export some specific attributes to a csv? My must have requirements are:

1. Pythonaddins, so that I can use the tool and click anywhere on polygon feature class.

2. There could be multiple feature classes, so I need to loop through all of them to get specific attributes to export.

[I think this would be very similar to identifier tool. The reason why we need to custom develop this, is to be able to export data to a csv file whenever a click event occurs.]

0 Kudos
1 Reply
Regular Contributor II

Hi Yamin,

I'm not sure if you still have this question. I haven't seen any users that have already created a tool similar to what you're needing.

Are you having trouble creating this tool on your end? If so, could you provide a code sample showing what you have so far? I would think that you would want to create a tool within a python addin that implements the following logic:

  1. Wire into the tool's onMouseDownMap event. This event will provide you with the xy location of where the user clicks.
  2. Implement logic that iterates through the layers in the TOC that you'd need to review and either use the selection Geoprocessing tools or cursors with a spatial filter to determine which layers have data that intersect where the user clicked.
  3. Use Geoprocessing to select the intersecting features and export them to a csv file via the  TableToTable conversion tool or using python create the csv file and write the needed records to using cursors.
0 Kudos