i worked in arcgis pro 2.4 , i need use attribute rule to make split feature line by feature point at intersect . how can i do that ?

1446
11
01-19-2020 02:19 PM
AliaaOssama
New Contributor

i worked in arcgis pro 2.4 , i need use attribute rule to make split feature line by feature point at intersect . how can i do that ?

0 Kudos
11 Replies
XanderBakker
Esri Esteemed Contributor

Hi Aliaa Ossama ,

There is an interesting blog here that could be a good starting point: Advanced Attribute Rules – Editing features on another class with attribute rules 

AliaaOssama
New Contributor

Dear Xander , 

thanks for your reply , this link is very useful , but i can't adopt the expression in my case

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Aliaa Ossama ,

Michael Miller has a GitHub repository with numerous Arcade examples for Atrribute Rules. Please have a look. For example this one: arcade-expressions/UpdateIntersectingFeature.md at master · MikeMillerGIS/arcade-expressions · GitHu... 

In your case you will have to select the feature that intersects and actually do the split using Intersection of the two geometries. Then perhaps update the geometry (and attributes?) with the first part and add the second part, or just add the two parts and delete the old line geometry.

0 Kudos
AliaaOssama
New Contributor

Hi Xander , 

the following expression i can not understand 100% 

var all_devices = FeatureSetByName($datastore, "WaterDevice", ["globalid"], true)var devices = Intersects(all_devices, $feature)var updates = []var i=0for (var device in devices){  updates[i++] = {'globalid': device.globalid,                'attributes': {'linevalue': $feature.ValueToCopy}               }}return {   'result': $feature.ValueToCopy,     'edit': [{        'className': 'WaterDevice',        'updates': updates                }]}

in my case i have feature line i need split it by feature point intersect it , in previous code ; 

1- where Put this expression ( in line feature class) ?

2- all device that mean point feature class ?

3- this expression create new feature or edit and split in existing feature 

sorry , i have low experience in arcade expression 

 

0 Kudos
XanderBakker
Esri Esteemed Contributor

HiAliaa Ossama ,

I assume that you want to trigger this attribute rule when you create a point feature and use that point feature to split a line. Is that your use case? Or what is your exact use case? What do these line features represent and what are the point features. Connectivity can exist between line and point features in a Utility Network even without splitting the line at the point location. 

0 Kudos
AliaaOssama
New Contributor

Hi Xander 

Yes , that is exactly my case (a point feature and use that point feature to split a line)

,appreciate your help, big thanks 

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Aliaa Ossama , 

I just had a detailed look at all the geometry functions: Geometry Functions | ArcGIS for Developers  and I come to the conclusion that there is no function that allows you to cut a line based on a point. The Cut function requieres a line to cut another line. When you intersect a line with a point, a point results. 

There is something you could do (see example below), but I really would like to advise against it:

// Create Point
var pointJSON = {"x": -3.0, "y": 5.0, 
                 "spatialReference": { "wkid": 3857 }};
var pnt = Point(pointJSON);
Console(TextFormatting.NewLine + "# Input point:")
Console(pnt);

// create small buffer around point
var buf = Buffer(pnt, 0.1);

// Create polyline
var polylineJSON = {
  "paths": [[[-10.0, 5.0], [10.0,5.0]]],
  "spatialReference": { "wkid": 3857 }
};
var line = Polyline(polylineJSON);
Console(TextFormatting.NewLine + "# Input line:")
Console(line);


// convert buffer to text and remove redundant parts
var txt = Text(buf);
txt = Mid(txt, 11, Count(txt)-11)
txt = Mid(txt, 0, Count(txt)-36);
txt = Replace(txt, '],[', '#');
txt = Replace(txt, '[', '');
txt = Replace(txt, ']', '');

// split list of pionts into array
var lst = Split(txt, '#');

// get points at 25% and 75% of list of points
var txtpnt1 = lst[Round(Count(lst)*0.25,0)];
var txtpnt2 = lst[Round(Count(lst)*0.75,0)];
var lstpnt1 = Split(txtpnt1, ',');
var lstpnt2 = Split(txtpnt2, ',');

// create line to use as cutter, use point as middle point
var polylineJSON = {
  "paths": [[[Number(lstpnt1[0]), Number(lstpnt1[1])], [pnt["X"],pnt["Y"]], [Number(lstpnt2[0]), Number(lstpnt2[1])]]],
  "spatialReference": { "wkid": 3857 }
};
var cutline = Polyline(polylineJSON);
Console(TextFormatting.NewLine + "# cut line:")
Console(cutline);

// Cut the line with the new line and extract both sides as results
var cutter = Cut(line, cutline);
// Console(cutter);
var result1 = cutter[0];
var result2 = cutter[1];
Console(TextFormatting.NewLine + "# result line 1:")
Console(result1);
Console(TextFormatting.NewLine + "# result line 2:")
Console(result2);


return "OK";‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Which will print the following to the console:

# Input point:
{"spatialReference":{"wkid":3857},"x":-3,"y":5}

# Input line:
{"spatialReference":{"wkid":3857},"paths":[[[-10,5],[10,5]]]}

# cut line:
{"spatialReference":{"wkid":3857},"paths":[[[-3,4.9],[-3,5],[-2.9934596870769856,5.09978589232386]]]}

# result line 1:
{"spatialReference":{"wkid":3857},"paths":[[[-10,5],[-2.9999999999999996,5]]]}

# result line 2:
{"spatialReference":{"wkid":3857},"paths":[[[-2.9999999999999996,5],[10,5]]]}

So, in theory you could cut a line with a point, but it would be better to have a standard Arcade function to do this.

0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Great idea for an AR.  I can see us using this for placing a valve on a water main.  Love a good challenge too.  This works in my very limited test.  Needs some more work and some polish.

arcade-expressions/SplitIntersectingLine.md at master · MikeMillerGIS/arcade-expressions · GitHub 

XanderBakker
Esri Esteemed Contributor

Hi mmiller-esristaff ,

Very cool example of an expression! Thanks for sharing. Do you think that in the future there will be a standard geometry function in Arcade for this?

0 Kudos