3 Replies Latest reply on Jun 14, 2017 7:51 AM by Neil Etheridge

    Populate Facility ID via Spatial Connectivity

    Jeff Garcia

      I have a table of service locations that have a field of Facility ID. All of the service locations have connectivity to the transformer bank layer. Is there a way with this connectivity relationship to create a GP script or steps to follow in order to populate the field in the service location table of facility ID to the Facility ID in the transformer bank layer that is the source? ArcFM GIS Support

        • Re: Populate Facility ID via Spatial Connectivity
          Neil Etheridge

          Hi Jeff,

           

          Do you have ArcFM Server implemented?  We have written a Python script previously which called the tracing services to do something very similar.

           

          Cheers,

          Neil

            • Re: Populate Facility ID via Spatial Connectivity
              Jeff Garcia

              Hi Neil,

               

              Yes we have ArcFM Server implemented. Where can I find that Python script?

                • Re: Populate Facility ID via Spatial Connectivity
                  Neil Etheridge

                  This should get you started. It demonstrates calling an upstream protective device trace then grabs the "UID" and "AssetNum" field values from the located protective devices.  You can find help on the ArcFM Server REST API here

                   

                  import arcpy, os, sys, time, inspect, getpass, argparse, math, requests, json
                  
                  
                  ...
                  
                  
                  traceService = "http://SERVER_NAME/arcgis/rest/services/ElectricDistribution/MapServer/exts/ArcFMMapServer"
                  protectiveDeviceLayerIds = "25,26,27"
                  
                  
                  ...
                  
                  
                  upstreamProtectiveTraceURL = "{0}/Electric%20Trace?startPoint={1}".format(traceService, traceStart.XY()) + \
                      "&traceType=NextUpstreamProtective&protectiveDevices={0}".format(protectiveDeviceLayerIds) + \
                      "&phasesToTrace=Any&drawComplexEdges=False&includeEdges=True" + \
                      "&includeJunctions=True&returnAttributes=False&returnGeometries=False" + \
                      "&tolerance=1&spatialReference=&f=json"
                  upstreamProtectiveTraceResults = requests.get(upstreamProtectiveTraceURL, auth=HTTPKerberosAuth())
                  upstreamProtectiveTraceJSON = json.loads(upstreamProtectiveTraceResults.text)                       
                  upstreamProtectiveTraceFeatureList = []
                  for featureResult in upstreamProtectiveTraceJSON["results"]:                            
                      featureClassName = featureResult["name"]
                      for feature in featureResult["features"]:
                          featureUID = feature["attributes"]["UID"]
                          featureAssetNum = feature["attributes"]["AssetNum"]
                  

                   

                   

                  Cheers,

                  Neil