|
POST
|
I tried the following, which seemed to work. This is outside ArcMap, but calls the CalculateField tool. import arcpy
table = r"C:\Temp\Default.gdb\LV"
arcpy.CalculateField_management(table,"group_code","''.join(i for i in !group_code! if i.isdigit())","PYTHON_9.3","#")
... View more
08-31-2016
03:27 PM
|
2
|
1
|
2526
|
|
POST
|
Try without the square brackets, something like: >>> string = "35$#"
>>> ''.join(c for c in string if c in '0123456789')
'35'
>>> ''.join(c for c in string if c.isdigit())
'35'
... View more
08-31-2016
12:28 PM
|
2
|
1
|
2526
|
|
POST
|
This builds on Joshua Bixby's comments and proposed solution. It assumes there are only 2 different types of corruption in your data - either the curve object has invalid data or the curve object is basically missing. Joshua's code fixes those features where the curve has invalid data. In the exception block, this code creates a curve object using the assumption that the curves are circles similar to all the others. This worked with the sample dataset. If there are additional types of corruption in the full dataset, you may need to modify the exception code. This solution requires 10.3 or higher. Load the feature in ArcMap and run the following code in the Python window. import json
cur = arcpy.da.UpdateCursor("POLE_arc", ["OID@","SHAPE@"])
for oid, shape in cur:
shape_dict = json.loads(shape.JSON)
try:
shape_dict["curvePaths"][0][1]["a"][2] = 0
shape = arcpy.AsShape(json.dumps(shape_dict), True)
cur.updateRow([oid, shape])
except:
x1 = shape_dict["curvePaths"][0][0][0]
y1 = shape_dict["curvePaths"][0][0][1]
x2 = x1 - 0.544675488298497
y2 = y1 - 0.540181258002587
shape_dict["curvePaths"][0][1] = {"a":[[x1,y1],[x2,y2], 0, 1, 1.57079632679, 0.80206559811, 0.999999999964]}
shape = arcpy.AsShape(json.dumps(shape_dict), True)
cur.updateRow([oid, shape]) And a thank you to Joshua.
... View more
08-18-2016
09:02 PM
|
0
|
0
|
2268
|
|
POST
|
Could you make an assumption that the exceptions (those like OID 10) are circles with a similar diameter, rotation, etc. and update the geometry, instead of converting them to points?
... View more
08-16-2016
09:28 PM
|
0
|
1
|
2268
|
|
POST
|
A clarification. As I mentioned, with ArcGIS Online the time is typically stored as UTC. However, Collector or a web browser will use its settings to display the time/date as local time. If you download the data as a file geodatabase, you may need to do a time conversion to get local time.
... View more
08-15-2016
10:28 AM
|
2
|
1
|
1012
|
|
POST
|
If you enable edit tracking for the feature, several fields will be created and automatically updated - Creation Date, Creator, EditDate and Editor. When your users collect a feature, the EditDate will show the time (usually in UTC) the feature was last edited and who the user was that did the edit.
... View more
08-12-2016
02:40 PM
|
4
|
2
|
1012
|
|
POST
|
This might simplify the field calculator code: def blah(f1,f2,f3,f4,f5):
params = locals() # dictionary of all arguments in function
return sum( v > 0 for k, v in params.iteritems()) or just: def blah(f1,f2,f3,f4,f5):
return sum( v > 0 for k, v in locals().iteritems()) I like the locals() function. Thanks Darren.
... View more
07-29-2016
04:42 PM
|
0
|
2
|
2347
|
|
POST
|
Here's a rewrite of your FindLabel function. It uses Blake's suggestions; there are a number of ways to do the same thing in Python. def FindLabel ([BLM], [BR], [Private], [SITLA]):
label_str = ""
if [BLM] : label_str += "BLM: {} acres\n".format([BLM])
if [BR] : label_str += "BR: {} acres\n".format([BR])
if [Private] : label_str += "Private: {} acres\n".format([Private])
if [SITLA] : label_str += "SITLA: {} acres\n".format([SITLA])
return label_str.strip()
... View more
07-15-2016
09:54 AM
|
2
|
0
|
1367
|
|
POST
|
If you are wanting to print the possible combinations, you wouldn't use an elseif. Try something like this (but adapted for FindLabel): BLM = 5.5
BR = None
PVT = 6.5
SITLA = 7.5
label_str = ""
if BLM : label_str = "BLM: " + str(BLM) + " acres\n"
if BR : label_str = label_str + "BR: " + str(BR) + " acres\n"
if PVT : label_str = label_str + "PVT: " + str(PVT) + " acres\n"
if SITLA : label_str = label_str + "SITLA: " + str(SITLA) + " acres\n"
find_label = label_str
print find_label
... View more
07-14-2016
02:10 PM
|
0
|
1
|
1367
|
|
POST
|
I've been watching the clock: python 2.7 countdown... Thanks.
... View more
07-08-2016
01:48 PM
|
0
|
3
|
5255
|
|
POST
|
I find typing a 'u' to specify a Unicode string helpful: input_X.replace(u'°',' ')
... View more
07-08-2016
11:44 AM
|
0
|
5
|
5255
|
|
POST
|
My next suggestion would be to look at the JSON file and check if the field definitions carried across correctly. For example, is the link field remaining a long/integer or is it becoming text? What type is the doctype field; text or other?
... View more
07-07-2016
02:09 PM
|
0
|
1
|
1065
|
|
POST
|
Do your field names contain reserved words or spaces? See: FAQ: What characters should not be used in ArcGIS for field names and table names? and FAQ: What are the reserved words for Esri's file geodatabase?
... View more
07-05-2016
12:26 PM
|
0
|
3
|
1065
|
|
POST
|
Since you are using an HTML form for the calculation, you do not need to put "calcExpression:" in the box. Just put the portion between the square brackets in the box (including the square brackets). This would go in the box: [{"field" : "EstDollarDamage", "sqlExpression" : "DwellingVal*PercentDamage*.01"}]
... View more
06-29-2016
09:34 PM
|
1
|
1
|
950
|
|
POST
|
The time used is epoch time (or Unix time) - the number of milliseconds since 1 Jan 1970 (usually in UTC, so you may need to convert to/from local time). Search for code that will convert to and from this time. Here's a python sample. import datetime, time
epoch_time = int(time.mktime(datetime.datetime.now().timetuple()) * 1000)
print epoch_time
print time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(epoch_time/1000)))
my_time = 1355245200000
print time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(my_time/1000)))
print int(time.mktime(time.strptime('2012-12-11 08:00:00','%Y-%m-%d %H:%M:%S'))* 1000)
... View more
06-27-2016
10:49 AM
|
1
|
1
|
765
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2016 02:23 PM | |
| 1 | 09-09-2017 08:27 PM | |
| 2 | 08-20-2020 06:15 PM | |
| 1 | 10-21-2021 09:15 PM | |
| 1 | 07-19-2018 12:33 PM |
| Online Status |
Offline
|
| Date Last Visited |
09-15-2025
02:54 PM
|