|
POST
|
Check out Re: Some users unable to get attachments. Timothy Hales said: Make sure you open the discussion up and are not viewing it in your Inbox or Activity Stream.
... View more
05-11-2015
02:52 PM
|
0
|
2
|
2146
|
|
POST
|
I noticed in the attribute table screenshot you posted earlier that the ItemIDs are coming through with a decimal. I originally assumed they were integer (LONG) but if they have a decimal it has to be DOUBLE. Please list all your fields and their data type so we are on the same page.
... View more
05-11-2015
01:01 PM
|
0
|
6
|
2476
|
|
POST
|
Subtypes would only be used to validate attributes, not geometry. I believe you would have to develop connectivity rules in your geometric network to accomplish what you mentioned. Using subtypes would only support the connectivity rules in the attribute table. ArcGIS Help 10.2 - About geometric network connectivity rules
... View more
05-11-2015
12:57 PM
|
1
|
4
|
3114
|
|
POST
|
Here's the code that is in the attachment. I posted this issue in the GeoNet Help place in hopes of getting an answer on the attachment issue. Some users unable to get attachments. def main():
import arcpy
import os
# Local variables
sourcegdb = r"N:\TechTemp\BlakeT\Work\TEMP.gdb"
table_in = os.path.join(sourcegdb, "SegmentSequence_input")
# Create output table
arcpy.CreateTable_management(sourcegdb, "SegmentSequence_output")
table_out = os.path.join(sourcegdb, "SegmentSequence_output")
arcpy.AddField_management(table_out, "UniqueID", "LONG")
arcpy.AddField_management(table_out, "Begin", "DOUBLE")
arcpy.AddField_management(table_out, "End", "DOUBLE")
arcpy.AddField_management(table_out, "SegmentItems", "TEXT", "", "", 255)
arcpy.AddField_management(table_out, "MaxDate", "DATE")
# Identify observation groups
sqlprefix = "DISTINCT UniqueID"
sqlpostfix = "ORDER BY UniqueID"
observations = tuple(uid[0]
for uid in arcpy.da.SearchCursor(
table_in,
["UniqueID"],
sql_clause=(sqlprefix, sqlpostfix)
)
)
fields_in = [
"ItemID",
"Begin_Station_Num_m",
"End_Station_Num_m",
"TestDate"
]
fields_out = [
"UniqueID",
"Begin",
"End",
"SegmentItems",
"MaxDate"
]
with arcpy.da.InsertCursor(table_out, fields_out) as i_cursor:
for obsv in observations:
# Read table into dictionary with rows as item: (begin, end, date)
where_clause = "UniqueID = {}".format(obsv)
itemsdict = {r[0]:(r[1], r[2], r[3])
for r in arcpy.da.SearchCursor(
table_in,
fields_in,
where_clause
)
}
# Identify segments
allsegments = [s[0] for s in itemsdict.values()] + [s[1] for s in itemsdict.values()]
segments = tuple(sorted(set(allsegments))) ## creates only unique segments
del allsegments
# Identify items and date in each segment
for i in range(len(segments)-1):
begin = segments
end = segments[i + 1]
seg_itemsdict = {k: v[2]
for k, v in itemsdict.items()
if v[0] <= begin and v[1] >= end
}
# Write segment items to output table
itemstext = str(seg_itemsdict.keys()).strip('[]')
itemsdates = [i for i in seg_itemsdict.values() if i is not None]
## Do not attempt to find max date if there
## are no dates for the items in the segment.
if len(itemsdates) > 0:
itemsdates_max = max(itemsdates)
else:
itemsdates_max = None
row = (obsv, begin, end, itemstext, itemsdates_max)
i_cursor.insertRow(row)
if __name__ == '__main__':
main()
... View more
05-11-2015
12:37 PM
|
0
|
10
|
2476
|
|
POST
|
Is it okay to have the gaps? The code can be adjusted if you need to leave those out.
... View more
05-11-2015
12:29 PM
|
0
|
12
|
2476
|
|
POST
|
I updated the code to accommodate missing dates. Attached is the updated code and copy of the output table. I did brief review of the output and there doesn't seem to be any duplicate segments. The only possible issue I see is that it is creating segments that do not have an ItemID. This is because there is a gap in begin and end values. See UniqueID 1446100 for an example.
... View more
05-11-2015
11:54 AM
|
0
|
20
|
2146
|
|
POST
|
Is that a data cleanup issue or does the code need to accommodate missing dates?
... View more
05-11-2015
09:36 AM
|
0
|
23
|
2146
|
|
POST
|
Can you briefly describe your data and the rules between valve type and junction type? What would be the two domains you want and how are they related?
... View more
05-11-2015
09:35 AM
|
1
|
6
|
3114
|
|
POST
|
That error is because some of your records are missing Date values. My code does not have any error handling and assumes there will always be at least one date.
... View more
05-11-2015
09:23 AM
|
0
|
25
|
2068
|
|
POST
|
Sorry, but I don't have that problem with the test data you posted. Please attach a copy of your input table (not a copy/paste) so I can test like for like. See my attachment on this post as an example.
... View more
05-11-2015
08:54 AM
|
0
|
28
|
2068
|
|
POST
|
Are you only looking at file geodatabases? Are they all in the same folder? Please describe your situation with more detail.
... View more
05-08-2015
04:35 PM
|
1
|
0
|
1940
|
|
POST
|
My eyes are starting to cross. Please test this and see if it's accurate. def main():
import arcpy
import os
# Local variables
sourcegdb = r"N:\TechTemp\BlakeT\Work\TEMP.gdb"
table_in = os.path.join(sourcegdb, "SegmentSequence")
# Create output table
arcpy.CreateTable_management(sourcegdb, "SegmentSequence_output")
table_out = os.path.join(sourcegdb, "SegmentSequence_output")
arcpy.AddField_management(table_out, "UniqueID", "LONG")
arcpy.AddField_management(table_out, "Begin", "DOUBLE")
arcpy.AddField_management(table_out, "End", "DOUBLE")
arcpy.AddField_management(table_out, "SegmentItems", "TEXT", "", "", 255)
arcpy.AddField_management(table_out, "MaxDate", "DATE")
# Identify observation groups
sqlprefix = "DISTINCT UniqueID"
sqlpostfix = "ORDER BY UniqueID"
observations = tuple(uid[0]
for uid in arcpy.da.SearchCursor(
table_in,
["UniqueID"],
sql_clause=(sqlprefix, sqlpostfix)
)
)
fields_in = [
"ItemID",
"Begin_Station_Num_m",
"End_Station_Num_m",
"TestDate"
]
fields_out = [
"UniqueID",
"Begin",
"End",
"SegmentItems",
"MaxDate"
]
with arcpy.da.InsertCursor(table_out, fields_out) as i_cursor:
for obsv in observations:
# Read table into dictionary with rows as item: (begin, end, date)
where_clause = "UniqueID = {}".format(obsv)
itemsdict = {r[0]:(r[1], r[2], r[3])
for r in arcpy.da.SearchCursor(
table_in,
fields_in,
where_clause
)
}
# Identify segments
allsegments = [s[0] for s in itemsdict.values()] + [s[1] for s in itemsdict.values()]
segments = tuple(sorted(set(allsegments))) ## creates only unique segments
del allsegments
# Identify items and date in each segment
for i in range(len(segments)-1):
begin = segments
end = segments[i + 1]
seg_itemsdict = {k: v[2]
for k, v in itemsdict.items()
if v[0] <= begin and v[1] >= end
}
# Write segment items to output table
itemstext = str(seg_itemsdict.keys()).strip('[]')
maxsegdate = max(seg_itemsdict.values())
row = (obsv, begin, end, itemstext, maxsegdate)
i_cursor.insertRow(row)
if __name__ == '__main__':
main()
... View more
05-08-2015
03:57 PM
|
0
|
34
|
2068
|
|
POST
|
I just noticed you have a negative number in there. Is that correct? Is that supposed to come before 0? Like this: -9.193 to 0 0 to 32.918 32.918 to 1303.02 ...
... View more
05-08-2015
01:52 PM
|
0
|
1
|
2728
|
|
POST
|
Have you ever heard of the term, "Scope Creep"? Seriously though, are there any other requirements we need to know about before spending time to solve your problem?
... View more
05-08-2015
01:15 PM
|
0
|
1
|
2728
|
| Title | Kudos | Posted |
|---|---|---|
| 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 | |
| 1 | 12-01-2025 06:19 AM |