0

I am running ArcGIS 10.1 Basic license with Python 2.7.2.

I have a two spatial files: the first listing vessel positions and the second activity on board. I also have a collection of reports in Excel which list events I must investigate by looking at that spatial data. All three files include an ID and a date-time field.

I want to be able to view the spreadsheet, using the mouse to work my way through the spreadsheet selecting events and then using the ID and the date-time to view the corresponding spatial data. I am thinking a Definition Query and then Zoom to Layer.

I need the flexibility to jump around in the spreadsheet -- perhaps weeks later jumping back into the spreadsheet and following up on the original investigation of a particular event. So, cycling through the spreadsheet in order with a cursor is not what I want.

I would also like to be able to update a field listing the status of the investigation.

The challenge, of course, is accessing that record manually selected from the spreadsheet and pulling out the ID and date time and updating the status of the event.

I have considered a few of approaches.

  1. Select the record outside of Python and then use button to activate a tool. The problem is that one cannot access the selection with Python.

  2. Start in the Python script and then select the record. Does anyone know how to display a table view in Python and then make a selection manually?

  3. Select the record manually outside of Python and then export the record to a named table or file. Start a Python script that always works with the named table or file and its single record.

I have searched this site and have not found anyone trying to do this. Can anyone offer advice?

  • are you tied to viewing the spreadsheet in Excel? Could it be imported to a file geodatabase table and viewed in ArcMap? – mr.adam Apr 14 '15 at 19:58
  • 1
    It is possible to access a selected feature in a layer with a Python add-in button. – Richard Law Apr 14 '15 at 20:05
  • There is additional functionality in a python addin for ArcGis but there are also restrictions. It sounds like a C#/VB.net addin is what you need... interoperability between Microsoft Excel and ArcGis is definitely achievable in .net using the exposed API. It might be possible to wrap the Excel objects for python but I can't say for sure. – Michael Stimson Apr 14 '15 at 22:33
  • Mr. Adam, I can certainly import the Excel spreadsheet to table in a file geodatabase. Whatever the table format -- Excel or file geodatabase -- the challenge remains accessing in ArcPy a record selected with the mouse. – Doug H Apr 14 '15 at 23:14
  • I suppose that there are limits to when dealing with Excel in ArcGIS. Let's say I import to a table in a file geodatabase, does that suggest any new approaches? – Doug H Apr 14 '15 at 23:23
1

You can create a Python add-in tool that first allows a user to select features (including with a mouse), and then executes a piece of logic on the selection. See the tutorial for an add-in Tool.

Any time you create an ArcPy search cursor on a layer, only the selected rows are returned.

In combination, you will be able to select features with your mouse, and then apply a search cursor only to that selection. It is also possible to programmatically read your Excel spreadsheet, but ultimately it's going to be joined into a Feature Class or Feature Layer.

  • Yes, since reading your and Michael 's replies I spent the day reading up on ArcPy Add-ins. Thanks. However, every example I have looked at involved a mouse click returning map coordinates to select a feature for editing, select a feature from which to pull off attributes... So far, though I have not seen any way to to use a mouse click to select a record in a table. I am being forced to agree with Michael that it is going to ArcObjects to expose that. It has been some years since I last wrote any VB ArcObjects. Now it would have to be VB.NET ArcObjects. – Doug H Apr 16 '15 at 1:55
  • The map selection and table selection are related. Couldn't you just have the table open and docked, with the "show only selected features" option on. Then as your mouse clicks change the selection, the row being displayed to you in the table will adjust automatically. Is there a problem with that? – Richard Law Apr 16 '15 at 1:57
  • The problem is that the reports do not have any spatial data. They are tables that say that this vessel on this day did this thing. The point of this tool would be to take the vessel ID and the date-time from the report and run a definition query followed by a zoom-to-layer to bring up the relevant vessel track in ArcMap to investigate what exactly the vessel did. Perhaps I can find some ArcObjects code for selecting records from tables with a mouse. It appears that at, 10.1 at least, ArcPy and ArcPy Add-ins do not offer a way to do this. – Doug H Apr 16 '15 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.