|
POST
|
Hi @AhmedElagroudy and @KimberlyGarbade , When creating Attribute Rules you need to be sure to check for anything that could go wrong along the way: For instance, when drawing your first line or any line that does not intersect another line, this will not return anything in the intersection and therefore "First" will fail. The intersection (and this somewhat surprised me) only seems to work on polygons You cannot cast the result of an intersection to a point And really, you should take a look at this great repository created by Mike Miller with a lot of examples: https://github.com/MikeMillerGIS/arcade-expressions/tree/master/attribute_rule_calculation In order to not overcomplicate the expression I did the following: Query the pipe featureset for all features that are not the current one Count the result of the intersects and if there is no pipe found (no intersection) do not return anything Create a small buffer of the current feature and of each intersecting pipe, Intersect the polygons Extract the centroid of the intersecting polygon Add the result(s) to an array to allow to add multiple points to the points layer Some more graphical explanations are below. The initial situation, lines in blue and intersecting points displayed with red crosses: Start drawing the line and create multiple intersections (only 1 per existing line): The intersecting points are added to the points layer: Now there are some things you will have to take into account: The points created are close to the intersection but not necessarily on the intersection since we are using a centroid of a polygon! So if you need the exact intersection you will need to explore the examples on Github to create a much more advanced expression to accomplish this. When your new line crosses an existing line it will create a point in the center of the multiple polygon sin the multipart intersection polygon. To avoid this you could convert the multipart to single-part and loop over each part to create the centroid. The expression used: var globid = $feature.GlobalID;
var sql = "GLOBALID <> @globid";
var pipes = Filter(FeatureSetByName($datastore, "pipe"), sql);
if (Count(pipes) > 0) {
var intersecting_features = Intersects(pipes, $feature);
var cnt = Count(intersecting_features);
var adds = [];
if (cnt > 0) {
var polf = Buffer($feature, 0.1, "m");
for (var pipe in intersecting_features) {
var poli = Buffer(pipe, 0.1, "m");
var polint = Intersection(poli, polf);
var pnt = Centroid(Polygon(polint));
Push(adds, {"geometry": pnt});
}
}
// don't try and return anything when there is no intersection!
if (Count(adds) > 0) {
return {
"edit": [
{"className": "test_point",
"adds": adds
}
]};
}
}
... View more
02-23-2022
02:26 PM
|
1
|
0
|
1309
|
|
POST
|
Hi @GIS_Rookie , So, ArcGIS has its labeling engine Maplex that has a lot of settings you can play with to get the result you want. I understand that it would be better to have them all point in a certain direction in this case. However, if you have a line that describes a circular movement, it would be best that in a certain location the text switches its orientation in order to be closer to horizontal and enable readability for the end-user. I also had some issues with the texts near the start or end of the line, not sure what is going on there.
... View more
02-17-2022
03:41 PM
|
1
|
0
|
1752
|
|
POST
|
Hi @GIS_Rookie , I suppose you can do something like this at the end of the script: # start insert cursor
flds_out = (fld_label, fld_angle)
with arcpy.da.UpdateCursor(fc, flds_out) as curs:
for row in curs:
lbl = row[0]
if lbl in dct_res:
angle = dct_res[lbl]
if angle < 0:
angle += 360
else:
pass
# angle = 400
curs.updateRow((lbl, angle, ))
... View more
02-17-2022
06:22 AM
|
1
|
2
|
1760
|
|
POST
|
Hi @GIS_Rookie , Thanks for sharing the sample of data. There are a couple of ways you can proceed. I created a line featureclass using the cut lines and changed it a bit to have it align to the left and I included the pole information for labeling. Have a look at the result below: See below the Python code I used (in the Python window of ArcGIS Pro): def getAngleLine(line):
pntg1 = arcpy.PointGeometry(line.firstPoint, line.spatialReference)
pntg2 = arcpy.PointGeometry(line.lastPoint, line.spatialReference)
return getAngle(pntg1, pntg2)
def createPerpendicularCutLine(pntg, angle, dist, sr):
pntg_cut_1 = pntg.pointFromAngleAndDistance(angle - 90, dist * 2.0, 'PLANAR')
pntg_cut_2 = pntg.pointFromAngleAndDistance(angle + 90, dist * 2.0, 'PLANAR')
cut_line = arcpy.Polyline(arcpy.Array([pntg_cut_1.firstPoint, pntg_cut_2.firstPoint]), sr)
return cut_line
def createCutLine(pntg, bearing1, buf, sr):
bearing2 = bearing1 + 180
pntg_cut_1 = pntg.pointFromAngleAndDistance(bearing1, buf * 1.5, 'PLANAR')
pntg_cut_2 = pntg.pointFromAngleAndDistance(bearing2, buf * 0, 'PLANAR')
cut_line = arcpy.Polyline(arcpy.Array([pntg_cut_1.firstPoint, pntg_cut_2.firstPoint]), sr)
return cut_line
def createLine(pntg1, pntg2, sr):
return arcpy.Polyline(arcpy.Array([pntg1.firstPoint, pntg2.firstPoint]), sr)
def getAngle(pntg1, pntg2):
return pntg1.angleAndDistanceTo(pntg2, method='PLANAR')[0]
import os
arcpy.env.overwriteOutput = True
# input fc
fc = r'D:\GeoNet\TransmissionLabel\point.shp'
fld_label = 'Pole'
fld_orden = 'Pole'
buf = 20
fc_out = r'D:\GeoNet\TransmissionLabel\cutline02.shp'
# spatial reference
sr = arcpy.Describe(fc).spatialReference
# dicts, listado para orden
flds = (fld_orden, 'SHAPE@')
dct_crds = {r[0]: r[1] for r in arcpy.da.SearchCursor(fc, flds)}
flds = (fld_orden, fld_label)
dct_lbl = {r[0]: r[1] for r in arcpy.da.SearchCursor(fc, flds)}
# create list of points and order list
lst_ptgs = [pntg for orden, pntg in sorted(dct_crds.items())]
lst_orden = sorted(dct_crds.keys())
# create output featureclass
ws, fc_name = os.path.split(fc_out)
arcpy.CreateFeatureclass_management(ws, fc_name, "POLYLINE", None, None, None, sr)
# add fields
arcpy.AddField_management(fc_out, fld_label, "TEXT", None, None, 50)
flds_out = ('SHAPE@', fld_label)
# empty lists for output features
lst_puntos = []
lst_lineas = []
lst_polylines = []
# start insert cursor
with arcpy.da.InsertCursor(fc_out, flds_out) as curs:
# first polygon
if len(lst_ptgs) >= 2:
pntg_1 = lst_ptgs[0]
pntg_2 = lst_ptgs[1]
angle_12 = getAngle(pntg_1, pntg_2)
cut_line = createPerpendicularCutLine(pntg_1, angle_12, buf, sr)
# generate and insert output row
lbl1 = dct_lbl[lst_orden[0]]
arcpy.AddMessage(' - procesar: {0}'.format(lbl1))
curs.insertRow((cut_line, lbl1, ))
# intermediate polygons
for i in range(1, len(lst_ptgs) - 1):
# read points
pntg_a = lst_ptgs[i - 1]
pntg_1 = lst_ptgs[i]
pntg_2 = lst_ptgs[i + 1]
# get angles and bearings
angle_1a = getAngle(pntg_1, pntg_a)
angle_12 = getAngle(pntg_1, pntg_2)
bearing_l = (angle_1a + angle_12) / 2.0
# create cut lines
cut_line = createCutLine(pntg_1, bearing_l, buf, sr)
# generate and insert output row
lbl1 = dct_lbl[lst_orden[i]]
arcpy.AddMessage(' - procesar: {0}'.format(lbl1))
curs.insertRow((cut_line, lbl1, ))
# last polygon
if len(lst_ptgs) >= 2:
pntg_1 = lst_ptgs[len(lst_ptgs) - 2]
pntg_2 = lst_ptgs[len(lst_ptgs) - 1]
# get angles and bearings
angle_21 = getAngle(pntg_2, pntg_1)
cut_line = createPerpendicularCutLine(pntg_2, angle_21, buf, sr)
# generate and insert output row
lbl1 = dct_lbl[lst_orden[len(lst_ptgs) - 2]]
arcpy.AddMessage(' - procesar: {0}'.format(lbl1))
curs.insertRow((cut_line, lbl1, )) The other way would be to write the angle to the points. This can be achieved like this: def getAngle(pntg1, pntg2):
return pntg1.angleAndDistanceTo(pntg2, method='PLANAR')[0]
import os
arcpy.env.overwriteOutput = True
# input fc
fc = r'D:\GeoNet\TransmissionLabel\point.shp'
fld_label = 'Pole'
fld_orden = 'Pole'
fld_angle = 'ANGLE2'
buf = 20
# spatial reference
sr = arcpy.Describe(fc).spatialReference
# dicts, listado para orden
flds = (fld_orden, 'SHAPE@')
dct_crds = {r[0]: r[1] for r in arcpy.da.SearchCursor(fc, flds)}
flds = (fld_orden, fld_label)
dct_lbl = {r[0]: r[1] for r in arcpy.da.SearchCursor(fc, flds)}
# create list of points and order list
lst_ptgs = [pntg for orden, pntg in sorted(dct_crds.items())]
lst_orden = sorted(dct_crds.keys())
dct_res = {}
# first polygon
if len(lst_ptgs) >= 2:
pntg_1 = lst_ptgs[0]
pntg_2 = lst_ptgs[1]
angle_12 = getAngle(pntg_1, pntg_2) + 90.0
# generate and insert output row
lbl1 = dct_lbl[lst_orden[0]]
dct_res[lbl1] = angle_12
# intermediate polygons
for i in range(1, len(lst_ptgs) - 1):
# read points
pntg_a = lst_ptgs[i - 1]
pntg_1 = lst_ptgs[i]
pntg_2 = lst_ptgs[i + 1]
# get angles and bearings
angle_1a = getAngle(pntg_1, pntg_a)
angle_12 = getAngle(pntg_1, pntg_2)
bearing_l = (angle_1a + angle_12) / 2.0
# generate and insert output row
lbl1 = dct_lbl[lst_orden[i]]
dct_res[lbl1] = bearing_l
# last polygon
if len(lst_ptgs) >= 2:
pntg_1 = lst_ptgs[len(lst_ptgs) - 2]
pntg_2 = lst_ptgs[len(lst_ptgs) - 1]
# get angles and bearings
angle_21 = getAngle(pntg_2, pntg_1) - 90.0
# generate and insert output row
lbl1 = dct_lbl[lst_orden[len(lst_ptgs) - 2]]
dct_res[lbl1] = angle_21
# start insert cursor
flds_out = (fld_label, fld_angle)
with arcpy.da.UpdateCursor(fc, flds_out) as curs:
for row in curs:
lbl = row[0]
if lbl in dct_res:
angle = dct_res[lbl]
else:
pass
# angle = 400
curs.updateRow((lbl, angle, ))
... View more
02-16-2022
09:47 AM
|
1
|
4
|
3759
|
|
POST
|
Hi @HeathAnderson , I must admit that I haven't touched ArcMap in over 2 years now, and there is no way I can validate the code, but let me see if we can get to the bottom of this. I assume that if you manually execute the report layout in ArcMap 10.8.1, it works, right? Checking the documentation I don't see a difference in the export tool between 10.6.x and 10.8.x. Please check that the root to the input layerfiles, the input report layout and the output pdf file are all valid and the layer can be added to ArcMap without problems and the report layout can be loaded into ArcMap. There is nothing wrong with your code as far as I can tell.
... View more
02-16-2022
06:59 AM
|
0
|
1
|
943
|
|
DOC
|
Hi @AJ_devaccount , I think your expression is hiding the columns (or cell data elements). The challenge is that the images will appear each on a new row. This is more an HTML question than an Arcade question. I did some quick tests and none of them resulted in having the cells appear on a single row. So if you can solve this HTML issue and incorporate it in the Arcade expression it should work. And just when I am about to post this I noticed that there is something you could do; use a single cell (column) and change the display "block" to "inline-block" inside the img tag. Have a look at the example below (just HTML no Arcade): <HTML>
<header>
</header>
<body>
<table style="table-layout:fixed" width="1000px">
<tr style="white-space: nowrap; overflow: hidden;">
<td>
<a href=""><img style="display:inline-block;" alt="hiking" src=""/></a>
<a href=""><img style="display:none;" alt="cycling" src=""/></a>
<a href=""><img style="display:inline-block;" alt="dog walking" src=""/></a>
<a href=""><img style="display:inline-block;" alt="photography and filming" src=""/></a>
<a href=""><img style="display:inline-block;" alt="birding" src=""/></a>
<a href=""><img style="display:none;" alt="kicksledding" src=""/></a>
<a href=""><img style="display:none;" alt="fat tire biking" src=""/></a>
<a href=""><img style="display:none;" alt="snoeshoeing" src=""/></a>
<a href=""><img style="display:inline-block;" alt="cross-county skiing" src=""/></a>
</td>
</tr>
</table>
</body>
</HTML>
... View more
02-15-2022
03:26 PM
|
0
|
0
|
33606
|
|
POST
|
Hi @GIS_Rookie , Then I suppose I have to reply with a question similar to the one I asked Paul. Do you have a sample of data that you can share? That will help understand what you have and what you are looking for.
... View more
02-15-2022
03:19 PM
|
0
|
5
|
3767
|
|
POST
|
Hi @DavidColey , You can do something like this (see below). Remember that the Distinct function returns and array and not a featureset: var intParcels = Intersects($feature, FeatureSetByName($map, 'Community Flood Zone'));
// this returns an array, not a featureset (and I sorted it)
var fpTypes = Sort(Distinct(intParcels, "zonetype"));
var fpCnt = Count(fpTypes);
var fplist = '';
if (fpCnt > 0) {
// create empty array
var lst = [];
// add the required text to the zones
for (var i in fpTypes) {
Push(lst, '- Zone: ' + fpTypes[i]);
}
// concatenate with new line
fplist = Concatenate(lst, TextFormatting.NewLine);
} else {
fplist = 'No Flood Zone intersects this parcel'
}
return fplist;
... View more
02-03-2022
11:41 AM
|
1
|
4
|
1682
|
|
POST
|
Hi @RonParis , A couple of changes (you are close): // Connect to featureset
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com/'), '[item_id]', 0);
// define the field name with the information you are looking for
var field_name = "Your Field Name goes here";
// buffer, filter and count (unchanged)
var buf = Buffer($feature, 500, "meter");
var fs_filtered = Intersects(fs, buf);
var cnt = Count(fs_filtered);
// some initial values
var min_dist = 999;
var result = "No feature found";
// first check if you have feature in the search distance
if (cnt > 0) {
// loop through the features found
for (var f in fs_filtered) {
// calculate distance
var dist = DistanceGeodetic($feature, f);
// check if it is closer than previous results
if (dist < min_dist) {
// got a hot, change the min dist and read the field
min_dist = dist;
result = f[field_name];
}
}
}
// return the result
return result;
... View more
02-03-2022
11:26 AM
|
1
|
1
|
5150
|
|
DOC
|
Hi @TSmith , Sorry for the delay in my reply. My first guess would be the date. You need to convert it to epochs to ensure that it is taken as a date when creating the featureset. You can do something like: var epoch = DateDiff(insdate, Date(1970, 0, 0));
... View more
01-26-2022
02:38 PM
|
0
|
0
|
10494
|
|
POST
|
Hi @AdamGebhart , You should be able to use the code after you create the item in your portal (this is just a reference to the data). You will have to change the ItemID to the one you create and the field and logic you want to apply after accessing the layer. I think the reason that I cannot access the website, is since it blocks access from Colombia:
... View more
01-26-2022
02:29 PM
|
0
|
1
|
743
|
|
POST
|
... and just tried, but I don't have access to the rest service you provided.
... View more
01-25-2022
10:54 AM
|
0
|
3
|
2846
|
|
POST
|
Hi @AdamGebhart , I continued with a map service (group layer) from a sample server and this is what I got: You are completely right that when adding a map service to the map, it will not provide access to the different layers in the same service. I thought that maybe the using the FeatureSetByPortalItem could be used. However, the layer is not a portal item in my portal To overcome this aspect I added a new item to my portal by referencing the map service. This provided the portal item ID that I need to access the other layers within the grouplayer Below you can see the classic web map with a group layer (map service: https://sampleserver6.arcgisonline.com/arcgis/rest/services/Military/MapServer) and the pop-up on the polygon areas show information from the intersecting units: Here's the expression I used: var spx = Portal('https://utility-esri-co.maps.arcgis.com');
var mili = FeatureSetByPortalItem(spx, 'e5cfe3e339394ffb82270e3791a32b6a', 2);
var fsint = Intersects(mili, $feature);
var result = "";
if (Count(fsint)>0) {
result = "Found " + Count(fsint) + " intersecting features:";
for (var f in fsint) {
result += TextFormatting.NewLine + " - " + f["SymbolName"];
}
} else {
result = "No intersection";
}
return result;
... View more
01-25-2022
10:53 AM
|
0
|
0
|
2846
|
|
POST
|
Hi @AdamGebhart , Thanks for sharing the map. However, I don't seem to have access to the services, so I can't really do anything at the moment. I can have a look at some of the sample Enterprise/ArcGIS Server services to see if I can replicate the situation. What version do you have for your Enterprise implementation?
... View more
01-25-2022
09:33 AM
|
0
|
6
|
2849
|
|
POST
|
Hi @AdamGebhart , So the limitation might be in the way the service is added to the map. Would it be possible to have access to the map to have a look? You could share it with a group and invite me to that group using "xbakker.spx".
... View more
01-25-2022
08:54 AM
|
0
|
8
|
2851
|
| Title | Kudos | Posted |
|---|---|---|
| 6 | 12-20-2019 08:41 AM | |
| 1 | 01-21-2020 07:21 AM | |
| 2 | 01-30-2020 12:46 PM | |
| 1 | 05-30-2019 08:24 AM | |
| 1 | 05-29-2019 02:45 PM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|