|
POST
|
I would prefer to get an event directly from the SketchViewModel. Something like "draw-complete" but for "draw-create." It looks like the on() method will let you register an event-handler but I'm not sure how to use it. Wish there were some samples or even a list of valid events!
... View more
04-17-2018
09:28 AM
|
0
|
0
|
3862
|
|
POST
|
I want to combine the SketchViewModel for sketching temporary geometries with the GeometryEngine to show a buffer around the graphic as it's being drawn. I can't figure out how to listen for create sketch in order to generate the buffer on mousemove.
... View more
04-16-2018
05:05 PM
|
0
|
10
|
5616
|
|
POST
|
What are you using to highlight the feature/graphic? I don't see that in your code.
... View more
04-09-2018
09:40 AM
|
1
|
0
|
4481
|
|
POST
|
From the documentation: Editor—Help | ArcGIS for Desktop stopEditing should not be called while an edit operation is in progress. Instead, abort the edit operation and stop the edit session.
... View more
04-03-2018
03:27 PM
|
1
|
0
|
1796
|
|
POST
|
Here's what I use edit = arcpy.da.Editor(workspace)
try:
edit.startEditing(multiuser_mode=True)
edit.startOperation()
with arcpy.da.InsertCursor(in_table, field_names) as cursor:
#
# do stuff
#
edit.stopOperation()
edit.stopEditing(save_changes=True)
except:
# Attempt to clean up edit session
try:
edit.abortOperation()
print "operation aborted in except"
edit.stopEditing(save_changes=False)
print "edit stopped in except"
except Exception as otherErr:
# Handle unexpected error when stopping edit
print otherErr
pass
# Re-raise original exception
raise
finally:
del edit You should be able to use Editor in a with statement to do all the cleanup automatically but I can never get it to work on versioned data.
... View more
04-03-2018
03:02 PM
|
0
|
0
|
1800
|
|
POST
|
Thanks, I also went looking at your other NumPy snippets #6 blog post.
... View more
04-02-2018
08:32 AM
|
0
|
5
|
13317
|
|
POST
|
Sorry Dan, I don't quite follow. So if I have a structured NumPy array like this: [
("one", "first"),
("two", None),
("three", "third"),
(None, "fourth")
] and I specify the structured NumPy array field data types all as '|S25', how can I ensure that the ArcGIS table that is created will have null values instead of a string 'None'?
... View more
03-30-2018
11:25 AM
|
0
|
1
|
13317
|
|
POST
|
I am querying data from another Oracle database, doing some work on the data, geocoding it, then appending it to a feature class in our enterprise geodatabase. I use ArcSDESQLExecute(), then NumPyArrayToTable() to pass into GeocodeAddresses_geocoding(). However, during the NumPyArrayToTable() process, null values always come through as a text string 'None'. I tried changing None values to numpy.NaN but those just come through as a string 'nan'. My datatypes for my numpy array fields are all string. How do you deal with null values with NumPyArrayToTable()?
... View more
03-30-2018
08:51 AM
|
0
|
10
|
17115
|
|
POST
|
On line 10, you've got the wrong syntax for get(). Should be: valueHub = hubDict.get(hub) But since you are iterating over the keys in the dictionary (as hub), you know the key exists so you don't need to use get()
... View more
03-29-2018
01:25 PM
|
0
|
0
|
1579
|
|
POST
|
Typically, no, it does not interfere. However, it can depend on how you're creating your query expression. Assuming my example valueDict above: for i in valueDict:
expression = "NAME = '{}'".format(valueDict[i])
print expression Output: NAME = 'Some Name'
NAME = 'Another Name'
NAME = 'Name Example'
NAME = 'And Another' This makes perfectly valid SQL. However, If you do something like this: names = tuple(valueDict.values())
expression = "NAME in{}".format(names)
print expression Output: NAME in(u'Some Name', u'Another Name', u'Name Example', u'And Another') It will keep the u designation and it won't be valid SQL. You would have to do something like: names = tuple(str(i) for i in valueDict.values())
expression = "NAME in{}".format(names)
print expression Output: NAME in('Some Name', 'Another Name', 'Name Example', 'And Another') But if you have exactly one name record in the dictionary, a single item tuple still has a comma at the end: NAME in('Some Name',) Which is not valid SQL. The best would be something like: names = ",".join("'{}'".format(i) for i in valueDict.values())
expression = "NAME in({})".format(names)
print expression Output: NAME in('Some Name','Another Name','Name Example','And Another') EDIT: Or, you could get rid of the u designation by converting row[0] to a plain string when you create the dictionary: valueDict = {}
with arcpy.da.SearchCursor(sourceFC, ["NAME"]) as cursor:
for enum, row in enumerate(cursor):
valueDict[enum] = str(row[0])
... View more
03-29-2018
09:04 AM
|
2
|
2
|
1579
|
|
POST
|
Indeed. The 'u' in front of the string values means the string has been represented as unicode. Letters before strings here are called "String Encoding declarations". Unicode is a way to represent more characters than normal ascii can manage. python - What does the 'u' symbol mean in front of string values? - Stack Overflow
... View more
03-29-2018
08:24 AM
|
1
|
4
|
10668
|
|
POST
|
If I'm understanding your request, I think this will get you what you need. I learned it's easy to enumerate a cursor for an index or key field. Here's the expanded code so you can see what's happening: valueDict = {}
with arcpy.da.SearchCursor(sourceFC, ["NAME"]) as cursor:
for enum, row in enumerate(cursor):
valueDict[enum] = row[0] This will build a dictionary like this: {
0: "Some Name",
1: "Another Name",
2: "Name Example",
3: "And Another"
}
... View more
03-29-2018
08:03 AM
|
1
|
8
|
10668
|
|
POST
|
Here's my experience with this adventure. https://community.esri.com/message/597806
... View more
03-26-2018
03:58 PM
|
1
|
1
|
4909
|
|
POST
|
Fixed in less than an hour! Love how just posting a problem can sometimes lead you to finding the answer yourself.
... View more
03-22-2018
04:15 PM
|
2
|
1
|
3633
|
|
POST
|
Thanks to Jibin Liu and Ghislain Prince for presenting this little gem at the 2018 Dev Summit in their session "Python: Working with Feature Data." This is an easy method of allowing you to access fields in your cursor by name instead of index number. def row_as_dict(cursor):
for row in cursor:
yield dict(zip(cursor.fields, row))
with arcpy.da.SearchCursor(table, fields) as cursor:
for row in row_as_dict(cursor):
print(row['RoadName'])
... View more
03-15-2018
02:53 PM
|
3
|
0
|
8437
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 1 | 10-23-2025 03:53 PM | |
| 1 | 04-28-2026 07:25 AM | |
| 1 | 03-19-2026 08:59 AM | |
| 1 | 02-12-2026 01:37 PM |