Select to view content in your preferred language

Dynamically add points to map

775
5
06-19-2012 08:31 PM
DanielNutsford
Emerging Contributor
Hi all,

I am trying to create a python script (or something of the sorts) that allows me to interactively add points to a .shp or FC by clicking on a map that is updated every X seconds. (This will be done from a helicopter where map updates are based on GPS location). I have been playing around with modelbuilder and feature sets which allows me to add the points interactively, however it stores all the points in the in__memory (I think) then adds them to a FC all at once. I want to be able to append a point to a FC as soon as it is added (i.e. as soon as I click on the map) as each point needs to have a unique timestamp.

I have some experience with python, and a little more with modelbuilder.

Any help would be awesome!

Cheers,
Dan
Tags (2)
0 Kudos
5 Replies
JimCousins
MVP Regular Contributor
How about incorporating an arcpy.CalculateField_management()?
You can acquire the current date/time with python module datetime:

import datetime
now = datetime.datetime.now()

Then you can supply this as the value to put into the field.
0 Kudos
DanielNutsford
Emerging Contributor
Thanks for your response Jim, that function will definitely come in handy. However I still have the problem of not being able to use it to calculate the date/time of each point individually as it is added to the map. If I was to put it in now it would say all points were added at the exact same time.

Below is the code I have exported straight from modelbuilder.

# Import arcpy module
import arcpy

# Set Geoprocessing environments
arcpy.env.scratchWorkspace = "D:\\dnutsford\\Thar_project"
arcpy.env.workspace = "G:\\Temp\\Daniel"

# Script arguments
points = arcpy.GetParameterAsText(0)
if points == '#' or not points:
    points = "in_memory\\{CC1D7814-D71D-4E29-8FB1-3CC188292BF4}" # provide a default value if unspecified

output_map = arcpy.GetParameterAsText(1)
if output_map == '#' or not output_map:
    output_map = "D:\\dnutsford\\Thar_project\\output_map" # provide a default value if unspecified

# Local variables:

# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(points, output_map, "", "", "OBJECTID OBJECTID VISIBLE NONE;SHAPE SHAPE VISIBLE NONE;an an VISIBLE NONE;numba numba VISIBLE NONE")


I am adding my points as the first parameter ('points') using a feature set as this allows me to interactively click on the display map. Im thinking that I need some way of iterating through the first parameter so that the script runs automatically each time the user clicks on the map display with the cursor. I can then append all the points to one feature class. Any help with the code required (or if it can be done in modelbuilder even better) would be much appreciated.

Cheers 

Dan
0 Kudos
KevinHibma
Esri Regular Contributor
I'm not sure I completely understand your workflow.
Exactly how are the points being entered - manually by someone at the computer? The GPS device logs the points to a file (or similar) and you will read points at a given time?

It sounds sort of like you're creating a tracking application?
When you say the map is updated every few seconds, how is it updated? Is this a map service and you want it to refresh the newly added points?

I'm sure what you're after is possible, I just dont understand how you want to implement.
0 Kudos
DarrenWiens2
MVP Honored Contributor
It seems like your question is more "how to dynamically calculate the time when a point is added" rather than "how to dynamically add a point" (that's what an edit session is for). I think the best way to do it would be to write a simple ArcObjects macro that listens for an event (adding a point) and then calculates the time in the table for that point. I think you're barking up the wrong tree trying to force this in Python, which doesn't listen for events.
0 Kudos
KevinHibma
Esri Regular Contributor
Ahhhh if thats what you're after (Darren's comments) - this is now available in 10.1 with editor tracking
http://resources.arcgis.com/en/help/main/10.1/index.html#//01m600000068000000
0 Kudos