TraceFilesToGeodatabase

Title  Trace Files To Geodatabase

Description

Converts the JSON files from a Utility Network trace to a geodatabase.

Usage

          
Only specify Utility Network if the output schema needs to be changed. The tool is additive, so new tables and fields can be added to an existing geodatabase.
The output geodatabase will always have the following tables prefixed with I_. Additional tables will be created based on Schema Options:
  • I_File - Stores the name of the JSON file and an incrementing ID
  • I_NetworkAttributes - Stores metadata about Utility Network network attributes
  • I_Pairs - Stores left/right fileKey values used in the difference views
  • I_Sources - Stores metadata about Utility Network source tables
  • I_SourceFilter - Stores the names of the sources, fields, and network attributes used when defining the output schema
The difference views can manually be configured by populating the I_Pairs table after loading at least 2 JSON files. For automatic loading, the following JSON can be added to each file which will be used to populate this table. The Batch Trace tool adds the JSON payload for you. { "traceInfo": { "name": "My Subnetwork", // This will be written to I_File. If not specified, the base name of the file will be used. "moment": 1693260302.855814, // This will be written to I_File. If not specified, the current time will be used. "key": "a", // Two files with the same value populates I_Pairs. "side": "left" // "left" represents current/original and "right" represents newer/modified. } }

License

Basic

Syntax

TraceFilesToGeodatabase (output_gdb, {truncate_tables}, {trace_files}, {controller_dataset}, {schema_options}, {output_options}, {source_filter_csv}, {source_filter_json})

Parameter Explanation Data Type
output_gdb Dialog Reference

The target geodatabase to convert the trace results files into.

DEWorkspace
truncate_tables (Optional) Dialog Reference

Truncates the tables listed in the I_Sources table.

GPBoolean
trace_files (Optional) Dialog Reference

JSON files from Trace or Export Subnetwork. If a folder is specified, it will be recursively traversed for JSON files.

GPComposite
controller_dataset (Optional) Dialog Reference

The Utility Network used to define the output schema. Leave blank if the output schema already exists.

GPUtilityNetworkLayer
schema_options (Optional) Dialog Reference

The tables to create in the Output Geodatabase

  • Associations: A table to store association records.
  • Attachment/Containment: A table to store structural attachment and containment associations.
  • Connectivity: A table to store from/to/via connectivity information. If Include Geometry is enabled, this table will be a polyline feature class.
  • Elements: A series of tables prefixed with E_ representing Utility Network elements. If Include Geometry is enabled, these tables will be feature classes.
  • Features: A series of tables prefixed with F_ representing Utility Network features. If Include Geometry is enabled, these tables will be feature classes.

GPString
output_options (Optional) Dialog Reference

Options enabled when a controller is provided.

  • Include Geometry: The outputs will include the geometry of the original elements and features.
  • Create Database Views: Creates a series of difference views. This requires Features to be selected.

GPString
source_filter_csv (Optional) Dialog Reference

A table with the sources to include and their fields and network attributes. Use the recordset to define the schema. This parameter cannot be used at the same time as Source Filter JSON.

GPRecordSet
source_filter_json (Optional) Dialog Reference

Specify one of the output trace results files to restrict the sources and fields in the results. This parameter cannot be used at the same time as Source Filter Table.

DEFile

Code Samples

TraceFilesToGeodatabase example 1 (Python window)

convert the trace results from trace_results1 and trace_results2 into features and elements in the report database

import arcpy

files = [
    r"c:\temp\trace_results1.json",
    r"c:\temp\trace_results2.json",
]
report_database = r"c:\temp\trace_report.geodatabase"
un = r"c:\temp\sample_un.geodatabase\network\utility_network"

arcpy.udms.TraceFilesToGeodatabase(report_database, un, files)

TraceFilesToGeodatabase example 2 (stand-alone script)

convert the trace results from trace_results1 and trace_results2 into features and elements in the report database

import arcpy

files = [
    r"c:\temp\trace_results1.json",
    r"c:\temp\trace_results2.json",
]
report_database = r"c:\temp\trace_report.geodatabase"
un = r"c:\temp\sample_un.geodatabase\network\utility_network"

arcpy.udms.TraceFilesToGeodatabase(
    output_gdb=report_database,
    controller_dataset=un,
    trace_files=files,
)