|
POST
|
You can check if the first format throws an error, and fix it if so. Also, you need to return the value in the end. from datetime import datetime
def fnElapsed(STRDTTM, ENDDTTM):
try:
dateStart = datetime.strptime(STRDTTM, "%d/%m/%Y %I:%M:%S %p")
except:
dateStart = datetime.strptime(STRDTTM, "%d/%m/%Y")
try:
dateEnd = datetime.strptime(ENDDTTM, "%d/%m/%Y %I:%M:%S %p")
except:
dateEnd = datetime.strptime(ENDDTTM, "%d/%m/%Y")
timeDiff = dateEnd - dateStart
return timeDiff.total_seconds()/60 note: my date formats are slightly different than yours.
... View more
04-21-2016
11:15 AM
|
2
|
1
|
3467
|
|
POST
|
I suspect what's happening is all of the values collected at the end of the submodel have the same name ("Lines","Lines","Lines",etc.). The layer names must be unique for the Merge tool (I believe this requirement is undocumented, but try it in ArcMap - it doesn't work). Try naming your collected values with iterator variable "%Value%" using inline variable substitution.
... View more
04-21-2016
10:54 AM
|
1
|
0
|
2607
|
|
POST
|
It's getting to the end of a long day and I'm having a hard time deciphering the problem on this one, so bear with me. If you want to know if a string starts with something, you can use the startswith() method: if myString.startswith('Interstate'):
return 'Interstate'
... View more
04-20-2016
03:16 PM
|
1
|
1
|
3188
|
|
POST
|
Here is a working example with my feature class and field names. Pay very close attention to where there are (and aren't) exclamation points.
... View more
04-20-2016
02:08 PM
|
1
|
0
|
2475
|
|
POST
|
Yes, SearchCursor works in the Field Calculator, although it's not very efficient because the function is run for every row in your dataset. So, for every row, the SearchCursor reads every row to load into the list. Likewise for the numpy solution, for every row, the table is transformed into a numpy array. I think the following sort of pattern may be better, although I'm not 100% sure of the sequence - happy to have someone clarify. I believe the following reads the list once (I switched over to the numpy solution), then refers to the list inside the function: my_list = arcpy.da.TableToNumPyArray('points','failure_sc')
my_max = max(my_list['failure_sc'])
def prob(Failure_Score):
global my_max
percentage = (float(Failure_Score)/my_max)*100
return percentage It's hard to say why you're getting nulls. Are your failure scores numeric?
... View more
04-20-2016
12:13 PM
|
1
|
3
|
4298
|
|
POST
|
Here is one way that seems to work in numpy, but I'm not an expert: def prob(Failure_Score):
my_list = arcpy.da.TableToNumPyArray('points','failure_sc') # change for your FC and field name
my_max = max(my_list['failure_sc']) # change for your field name
percentage = (float(Failure_Score)/my_max)*100
return percentage
... View more
04-20-2016
12:09 PM
|
0
|
0
|
4298
|
|
POST
|
Ignoring numpy for the moment, you can load your list via a SearchCursor: def prob(Failure_Score):
my_list = [i[0] for i in arcpy.da.SearchCursor('points','failure_sc')] # change to suit your feature class and field name
my_max = max(my_list)
percentage = (float(Failure_Score)/my_max)*100
return percentage
... View more
04-20-2016
11:54 AM
|
2
|
5
|
4298
|
|
POST
|
Well, why bother using all those ArcGIS/arcpy tools? You can just manipulate the Excel through Python.
... View more
04-19-2016
09:45 AM
|
1
|
0
|
1035
|
|
POST
|
And you're using LON=x, LAT=y, and not the other way around?
... View more
04-18-2016
12:10 PM
|
1
|
0
|
2479
|
|
POST
|
There are lots of possible problems moving Excel to ArcGIS, but I'd say the most common one is that your field names have either spaces (even trailing spaces) or special characters in any of your field names. Make the field names as simple as possible and try again.
... View more
04-18-2016
11:46 AM
|
0
|
1
|
2479
|
|
POST
|
For your own sanity, I'd keep it simple as possible - it is so painful trying to anticipate every little thing the user can do to break your system. If possible, you should only give them the option to enter data correctly. I agree you should request a standardized format. You may also consider using a database that can take advantage of data validation upon entry (like an FGDB domain, although which DB you choose will depend on your setup).
... View more
04-18-2016
09:37 AM
|
1
|
1
|
3443
|
|
POST
|
This sounds like something accomplished with a join (on parcel number) then field calculate status.
... View more
04-18-2016
08:56 AM
|
1
|
3
|
3443
|
|
POST
|
You can copy tables using Copy Rows and feature classes using Copy Features, but curiously, it seems as though Copy Rows does not respect raw path notation. >>> arcpy.CopyRows_management("myfeatureclass",r'in_memory\table')
Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 14392, in CopyRows raise e ExecuteError: ERROR 000210: Cannot create output in_memory\table Failed to execute (CopyRows).
>>> arcpy.CopyRows_management("myfeatureclass",r'in_memory\mytable')
<Result 'in_memory\\mytable'> edit: on further inspection, it's not a problem reading raw notation, it is a problem creating a table named "table".
... View more
04-15-2016
01:02 PM
|
1
|
1
|
2963
|
|
POST
|
Can you give us unfamiliar with the term "Euclidean similarity matrix" a simple description of what you're looking for? One sentence or less, please
... View more
04-15-2016
12:55 PM
|
0
|
0
|
1115
|
|
POST
|
Not sure I understand, but you can export the feature class table to a standalone table, from within the attribute table options:
... View more
04-14-2016
03:12 PM
|
1
|
1
|
3327
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-25-2015 01:51 PM | |
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|