|
POST
|
To post code: function ArrayEquals(arr_1, arr_2) {
if(Count(arr_1) != Count(arr_2)) { return false }
arr_1 = Sort(arr_1)
arr_2 = Sort(arr_2)
for(var i in arr_1) {
if(arr_1[i] != arr_2[i]) { return false }
}
return true
}
function IncludesArray(outer, inner) {
for(var i in outer) {
if(ArrayEquals(outer[i], inner)) { return true }
}
return false
}
if (IncludesArray(tagt, fagt)){
//...
... View more
04-26-2023
06:34 AM
|
1
|
0
|
1908
|
|
POST
|
It's possible to do that with the Field Calculator and Arcade. The expression is probably going to be pretty complex because there aren't built-in functions to snap, but I have written some functions for other projects. How do you determine which edge a point belongs to? Do they have an attribute? Or are you just using the closest line?
... View more
04-25-2023
12:09 PM
|
0
|
1
|
1712
|
|
POST
|
Let me start by saying that this is not a task for ModelBuilder. ModelBuilder can automate chains of geoprocessing tools. As soon as you need user input (like inserting a feature), it's going to get complicated. This is a job for Python. input_table = "TestLines"
input_field = "IntegerField1"
output_location = "memory" # default gdb
output_name = "SomeName"
# create ouput
out_table = arcpy.management.CreateTable(output_location, output_name)
# start inserting into the output table
with arcpy.da.InsertCursor(out_table, ["OID@"]) as i_cursor:
# open the input table to read the field
with arcpy.da.SearchCursor(input_table, [input_field]) as s_cursor:
for row in s_cursor:
# insert x rows
x = row[0]
for y in range(x):
i_cursor.insertRow([None])
# stop after the first row of the input table
break Now that that's out of the way: You can do it with ModelBuilder, but it's much more complicated... There are iterators for the ModelBuilder, but they execute the whole model x times. Because we only want to loop a part of the model (add a feature x times), we need a separate model to do that. There is no geoprocessing tool that inserts a feature into a table. You could create a script tool and use that, but then you could just do it in Python completely. So we're using the Append tool. For that to work, you need a template table with exactly one feature. The submodel will append that template table x times to the output table. Negative: You need an extra table. Positive: You can easily add/remove fields to/from your output table by just changing the fields of your template table, you don't need to change the model. So, let's create the submodel first: It has three parameters: The input and taget datasets of the Append tool, and X, the number of times we want to execute the tool. X is just a Long variable: The For iterator increases a value every time the tool is executed, until it reaches the target value (X). The iterator behaves differently from what I expected. In programming languages, "for(y = 0; y < x; y++)" loops exactly x times. The iterator loops x + 2 times. I haven't worked with ModelBuilder much, and never with the iterators, so I don't know if that is expected and how best to circumvent that. I chose to check if the current iteration value is less than X and hooked the True output to the Append as precondition. The actual model looks like this: It has 5 parameters: Output Location and Output Name control the path of the output table. Template Table is the mentioned table with exactly one feature. Input Table and Input Field are the table and field from where the tool gets the number of rows to insert (it only looks at the first row. If you input a layer with a selection, it only looks at the first row of the selection). Output Location, Output Name, and Template Table are used to create an empty copy of the Template Table (Create Table tool). Get Field Value gets the target number of rows. And then we execute our submodel with the newly created Output Table as Target Dataset, the Template Table as Input Dataset (that's why it is important that it has exactly one feature), and X as X. This is my Template Table: This is my Input Table (Input Field is IntegerFIeld1): The tool: And the generated output: Note that it inserted 3 features, because that is the first selected row in the Input Table. Without selection, it would have inserted 5.
... View more
04-25-2023
11:55 AM
|
0
|
1
|
1113
|
|
POST
|
I mean, you can get the sum of all the jurisdiction taxes that intersect the currently selected jurisdiction. But that probably won't be the correct tax rate for the specific coordinate you clicked on. As long as there is no way to get coordinates in Arcade, your best bet is probably to precompute the tax sums.
... View more
04-25-2023
09:03 AM
|
0
|
0
|
1678
|
|
POST
|
Ah OK. So you want something like this: // load your featureset
var fs = FeaturesetByPortalItem(Portal("https://arcgis.com"), "b0d335151aad48a5883326b9aed69cdd", 0, ["TextField1", "TextField2"], false)
// define the output featureset
var out_dict = {
fields: [
{name: "Project_Name", type: "esriFieldTypeString"},
{name: "Current_Step", type: "esriFieldTypeString"}
],
features: [],
geometryType: ""
}
// iterate over the input fs
for(var f in fs) {
// split the Current_Steps field
var project_name = f.TextField1
var steps = Split(f.TextField2, ",")
// iterate over the split values
for(var s in steps) {
// create a new feature in the output featureset
var new_f = {attributes: {Project_Name: project_name, Current_Step: Trim(steps[s])}}
Push(out_dict.features, new_f)
}
}
Console(out_dict)
// return the featureset
return Featureset(Text(out_dict)) Change the field names in lines 1, 17, 18. I used "TextField1" for the project name and "TextField2" for the current step. You can use that expression to generate a featureset with the project name and the split values. You can then input that fs into the pie chart widget: Add a side or top bar widget. In there, you can add a category selector. Point it to the data expression and use the project name column as group field: Set the category selector to filter the pie chart: This is a quick example. The table on the left is my input featureset. The table on the right is the output of the data expression. The pie chart uses the same data expression. When I select a project, each widget gets filtered to show only features that belong to that project:
... View more
04-25-2023
02:25 AM
|
1
|
3
|
3948
|
|
POST
|
To post code: I don't really understand what you want to achieve. You have one featureset with a field "Current_Step", which apparently contains lists of values (you split by "(", shouldn't that be "," ?) And you have a featureset with a field "Project_Name". How are these two tables related? Do they have a common field? Do they have spatial overlap?
... View more
04-24-2023
02:49 PM
|
0
|
5
|
3964
|
|
POST
|
You have to contact the Community team at [email protected] , they'll change it for you.
... View more
04-24-2023
02:29 PM
|
3
|
0
|
2018
|
|
POST
|
Do it in a table: var public_date = Text(Now(),'dddd, MMMM D, Y @ hh:mmA')
var img_url = "https://wpsgn.maps.arcgis.com/sharing/rest/content/items/7571b914c3fc40929328a5be04331759/data"
return {
type: "text",
text: `<table><tr>
<td><img src="${img_url}" width="30px"></td>
<td style="padding-left: 10px;">Public meeting is scheduled for <br/> <strong>${public_date}</strong></td>
</tr></table>`
}
... View more
04-24-2023
02:18 PM
|
1
|
1
|
1975
|
|
POST
|
If I understand correctly, you want to just click anywhere in the map and show the sum of all tax rates at that coordinate? That's currently not possible with Arcade, as there is no way to get the map coordinate you clicked on. However, if you have features you can click on (say, address points or parcels), you can do it with an expression like this: var districts = FeaturesetByName($map, "TaxRateLayer")
var i_districts = Intersects($feature, tax_districts)
return Sum(i_districts, "TaxRateField")
... View more
04-24-2023
02:06 PM
|
0
|
2
|
1689
|
|
POST
|
I'm assuming that an attribute rule needs to be added to the point feature class Correct. The easiest way is to remove lines 5-10 from the rule on the line fc and add this rule to the point fc: // Calculation Attribute Rule on the point fc
// field: leave empty
// triggers: insert, update
// exclude from application evaluation
var lines = FeaturesetByName($datastore, "TestLines")
var i_lines = Intersects($feature, lines)
var updates = []
for(var i_line in i_lines) {
Push(updates, {globalID: i_line.GlobalID})
}
return {edit: [{className: "TestLines", updates: updates}]} This issues an update request to all intersecting line features, so their rule will be executed and they find the intersecting points on their own. This will slow things down in bulk updates if you have big point and/or line fcs. The point rule will do the intersect, then each intersected line will do the intersect again. Also, the line rule will now calculate the fields in each update, not just the geometry updates. A better way would be to leave the line fc rule as it is and check for intersection with start or end point in the point fc. You can get the first element of an array with the index 0, the last element with the index -1. A line geometry is an array (multipart) of arrays (parts) of points. See lines 10 & 11. // Calculation Attribute Rule on the point fc
// field: leave empty
// triggers: insert, update
// exclude from application evaluation
var lines = FeaturesetByName($datastore, "TestLines")
var i_lines = Intersects($feature, lines)
var updates = []
for(var i_line in i_lines) {
var start_point = Geometry(i_line).paths[0][0]
var end_point = Geometry(i_line).paths[-1][-1]
if(Intersects($feature, start_point)) {
Push(updates, {globalID: i_line.GlobalID, attributes: {IntegerField1: $feature.OBJECTID}})
}
if(Intersects($feature, end_point)) {
Push(updates, {globalID: i_line.GlobalID, attributes: {IntegerField2: $feature.OBJECTID}})
}
}
return {edit: [{className: "TestLines", updates: updates}]} Be sure to change to your fields and table names! I used IntegerField1, IntegerField2, and OBJECTID.
... View more
04-24-2023
01:46 PM
|
1
|
2
|
4138
|
|
POST
|
If you hover over the red square, it should tell you what's wrong. Common reasons you can't save a rule: You forgot to add GlobalIDs to the feature class You forgot to set a trigger event Error in your script You're editing the feature class (though that will deactivate the save button, not show the red square)
... View more
04-23-2023
10:28 AM
|
2
|
0
|
3963
|
|
POST
|
I guess (!) this is another case of this phenomenon, where accessing a featureset for the first time takes a lot of time. If that is the case, then the number of lines and states for a particular trail doesn't really matter, only the total number of lines and states. But 2-3 minutes is really excessive. Sadly, I don't really have an idea for making it faster right now. Maybe consider precomputing those numbers, as they seem to be static.
... View more
04-21-2023
03:39 PM
|
1
|
0
|
1848
|
|
POST
|
Myabe you can do it in one GroupBy (@jcarlson is the master of that), but I couldn't find a way, so I did it iteratively. var fs = Featureset('{"geometryType":"","fields":[{"name":"TRLNAME","type":"esriFieldTypeString"},{"name":"STATE","type":"esriFieldTypeString"},{"name":"CONG_DIST","type":"esriFieldTypeString"}],"features":[{"attributes":{"TRLNAME":"Trail 1","STATE":"State 1","CONG_DIST":"District 1"}},{"attributes":{"TRLNAME":"Trail 1","STATE":"State 1","CONG_DIST":"District 1"}},{"attributes":{"TRLNAME":"Trail 1","STATE":"State 1","CONG_DIST":"District 2"}},{"attributes":{"TRLNAME":"Trail 2","STATE":"State 2","CONG_DIST":"District 3"}},{"attributes":{"TRLNAME":"Trail 2","STATE":"State 2","CONG_DIST":"District 4"}},{"attributes":{"TRLNAME":"Trail 3","STATE":"State 3","CONG_DIST":"District 5"}},{"attributes":{"TRLNAME":"Trail 3","STATE":"State 4","CONG_DIST":"District 6"}},{"attributes":{"TRLNAME":"Trail 3","STATE":"State 5","CONG_DIST":"District 7"}},{"attributes":{"TRLNAME":"Trail 3","STATE":"State 6","CONG_DIST":"District 8"}},{"attributes":{"TRLNAME":"Trail 3","STATE":"State 7","CONG_DIST":"District 9"}}]}')
var out_fs = {
geometryType: "esriGeometryPolyline",
fields: [
{name: "Trail", type: "esriFieldTypeString"},
{name: "States", type: "esriFieldTypeInteger"},
{name: "Districts", type: "esriFieldTypeInteger"},
],
features: []
}
for(var trail in Distinct(fs, ["TRLNAME"])) {
var name = trail.TRLNAME
var filtered = Filter(fs, "TRLNAME = @name")
var att = {
Trail: name,
States: Count(Distinct(filtered, ["STATE"])),
Districts: Count(Distinct(filtered, ["CONG_DIST"])),
}
var geometries = []
for(var f in filtered) { Push(geometries, Geometry(f)) }
Push(out_fs.features, {geometry: Union(geometries), attributes: att})
}
return Featureset(Text(out_fs))
... View more
04-21-2023
03:32 PM
|
1
|
0
|
1794
|
|
POST
|
// load the layers
var points = FeaturesetByPortalItem(...)
var polygons = FeaturesetByPortalItem(...)
var n = 0
// iterate over the points
for(var p in points) {
// if it intersects one or more polygons, increase the counter
if(First(Intersects(p, polygons)) != null) {
n++
}
}
// return a featureset with one field and one feature
var out = {
geometryType: "",
fields: [ {name: "Inside", type: "esriFieldTypeInteger"} ],
features: [{attributes: {Inside: n}}]
}
return Featureset(Text(out)) You can then use the MIN/MAX/SUM of this field in your indicator.
... View more
04-21-2023
02:45 PM
|
0
|
0
|
1760
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-30-2023 09:57 AM | |
| 1 | 05-18-2023 12:51 AM | |
| 1 | 03-05-2023 12:46 PM | |
| 1 | 12-07-2022 07:01 AM | |
| 1 | 06-21-2022 08:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
02-03-2024
06:14 PM
|