|
POST
|
var description = $feature.PointDescription
var lz = Find('LOADING ZONE',description)
IIf(lz == -1, 'Y', 'N') // 'LOADING ZONE' not found -> 'Y' You could also replace 'LOADING ZONE' and check if the description has changed: var description = $feature.PointDescription
var repl_description = Replace(description, 'LOADING ZONE', '')
IIf(repl_description == description, 'Y', 'N' )
... View more
02-23-2023
12:45 AM
|
2
|
1
|
1553
|
|
POST
|
Here's the problem: arcpy.management.CalculateField(inTable, "TextField", "some text")
# the tool will try to evaluate the expression. Internally, it will try to run this:
def expression():
return some text
# this of course fails, because it's not valid syntax, and because it evaluates _some_ and _text_ as variales, and they aren't defined
# to fix that, you have to correctly escape your strings:
arcpy.management.CalculateField(inTable, "TextField", "'some text'")
def expression():
return 'some text' Here's how you can fix it: arcpy.management.CalculateField(inMosaic, "YEAR", "'{}'".format(yearfield))
... View more
02-23-2023
12:37 AM
|
0
|
1
|
2139
|
|
POST
|
You said that $feature.Date is a double. You compare it to a string. Your condition will always be true, so the else block will never be entered.
... View more
02-22-2023
01:23 AM
|
1
|
0
|
3584
|
|
POST
|
I have a map that has multiple feature classes/services. They are project locations for different groups with basic attribute information like Project ID, Name, Type, Description, Project Manager, Estimated Begin and End date. I was originally thinking of using the intersect and proximity functions in Arcade to create a pop up for projects that intersect or come within a certain proximity of each other and have overlapping dates. Now thinking about it (it would be too busy with too many pop ups), it would probably be better to have a list generated that calls out projects that overlap or come within close proximity of each other and have overlapping dates instead of single pop ups for the whole map area. Is this possible with just Arcade? Are there any existing similar examples of this? And how would one go about this? Or would this need to be a web app with custom Java/Python scripting? Thanks for any insight. You can list the overlapping projects in a popup: // load all project layers (including this one!)
var other_project_fcs = [
FeaturesetByName($map, "TestPoints"),
FeaturesetByName($map, "TestLines"),
FeaturesetByName($map, "TestPolygons"),
]
// buffer your project geometry
var project_buffer = Buffer($feature, 250, "feet")
var other_projects = []
// iterate over the project layers
for(var i in other_project_fcs) {
// find all projects intersecting the current project (buffered)
var nearby_projects = Intersects(project_buffer, other_project_fcs[i])
// iterate over those projects
for(var project in nearby_projects) {
// skip if the intersecting project is the current $feature
if($feature.ProjectID == project.ProjectID) { continue }
// get start and end dates
var start1 = $feature.BeginDate
var end1 = $feature.EndDate
var start2 = project.BeginDate
var end2 = project.EndDate
// skip if there is no time overlap
if(start1 > end2 || start2 > end1) { continue }
// calculate the time overlap
var overlap_start = Date(Max([Number(start1), Number(start2)]))
var overlap_end = Date(Min([Number(end1), Number(end2)]))
var overlap = DateDiff(overlap_end, overlap_start, "days") + 1
// describe the overlapping project
var dist = Round(Distance($feature, project, "feet"), 0)
var runtime = Text(start2, "MM/DD/Y") + " - " + Text(end2, "MM/DD/Y")
var project_text = [
"Project: " + project.Project,
"Contact: " + project.Contact,
"Distance: " + dist + " feet",
"Runstime: " + runtime,
"Overlap: " + overlap + " days"
]
// append the desription to the array
Push(other_projects, Concatenate(project_text, "\n"))
}
}
// concatenate the descriptions and return
return Concatenate(other_projects, "\n\n") You can modify the expression to fill a featureset with all pairs of overlapping projects and feed that featureset into a list widget in a Dashboard or Experience, no custom javascript neccessary.
... View more
02-22-2023
01:18 AM
|
1
|
4
|
4049
|
|
POST
|
Ah, joins. When you add a join to a table, the full name of the field is used: Tablename.Fieldname (you can see that in your screenshot, too). Clean solution: Instead of adding a join, use Join Field to permanently join the point count field to the polygons. This will change the polygon feature class, so it might not be possible for you. Messy solution: use the full field names. I downloaded the polygons and replicated your workflow: run the Summarize Nearby tool on the polygons and a point fc, join the output to the National Parks. My feature class names are "National_Parks__England____Natural_England" for the original polygons and "parks_near" for the parks with summarized points. This expression works for me: // order the layer
var ordered = OrderBy($layer, "(parks_near.Point_Count / National_Parks__England____Natural_England.Shape_Area) DESC")
var rank = 0
// iterate over the ordered layer
for(var f in ordered) {
// increase the rank
rank++
// if the feature we're looking at is the feature we clicked on, return the current rank
if(f['National_Parks__England____Natural_England.OBJECTID'] == $feature['National_Parks__England____Natural_England.OBJECTID']) {
return rank
}
}
... View more
02-21-2023
10:32 AM
|
0
|
1
|
4866
|
|
POST
|
It's quite hard to follow your question, because your screenshot doesn't fit your text (polygons aren't labeled, colors are wrong)... Are the blue lines what you want?
... View more
02-21-2023
09:56 AM
|
1
|
1
|
2634
|
|
POST
|
In your other answer, Arcade is complaining about census being empty. To solve that, replace line 4 in the script above: if($feature.Date == 2019 || IsEmpty($feature.census)){
return '0'
}
... View more
02-21-2023
09:52 AM
|
0
|
0
|
3636
|
|
POST
|
What field types are date and census? Try this: // invert your condition and return the default value early.
// that makes the following code easier to follow, because
// you don't need the extra else block
if($feature.Date == 2019){
return '0'
}
var census = $feature.census; // take the "pure" value instead of Text()
var startDate = 2019;
var features = Filter($featureSet, "date = @startDate AND census = @census");
var featureFirst = First(features);
if(featureFirst == null){
return '0'
}
var growth = (($feature.Totals_by_Tract_by_Sector/featureFirst.Totals_by_Tract_by_Sector)-1)*100;
return growth
... View more
02-21-2023
09:26 AM
|
1
|
3
|
3642
|
|
POST
|
var address = "200 Fifth Avenue: Manhattan"
return Split(address, ":")[0]
... View more
02-21-2023
08:57 AM
|
0
|
0
|
796
|
|
POST
|
To post code: While many programming languages use the operator && as logical and, SQL uses "AND". So your query in line 4 should be "date = @startDate AND census = @census" Also, you're missing a null check after line 4. If the Filter function returns an empty featureset (nothing found with this query), First() will return null, and then you'll get an error in line 6, when you call null.SomeField After line 5, insert something like this: if(dic == null) { return '0' } // I guess this is your default value, judging from line 9
... View more
02-21-2023
08:54 AM
|
0
|
5
|
3665
|
|
POST
|
If the features in Camino and Camino_3D are in the same order, you can just use this script. If your screenshot was just for testing and you have another structure, you need to explain that structure.
... View more
02-21-2023
04:20 AM
|
0
|
1
|
2526
|
|
POST
|
// order the layer
var ordered = OrderBy($layer, "(PointCount/Shape_Area) DESC")
var rank = 0
// iterate over the ordered layer
for(var f in ordered) {
// increase the rank
rank++
// if the feature we're looking at is the feature we clicked on, return the current rank
if(f.OBJECTID == $feature.OBJECTID) {
return rank
}
} If you use this expression in the popup, it will recalculate the rank each time you click on a feature. This is good for dynamic data, but it will slow down the popup somewhat. If you have static data (train stations and national parks sound pretty static), it might be better to use the expression to calculate a new field and show that in the popup.
... View more
02-20-2023
11:39 PM
|
0
|
1
|
4887
|
|
POST
|
Your expression fails in line 37. fsID is "$1000-$1100". The sql query you're constructing is "SplitChoices = $1000-$1100". This is an invalid query, you need "SplitChoices = '$1000-$1100'", note the single quotes. You could use the @ notation, that will handle the field type for you: "SplitChoices = @fsID" Or you could do it yourself with template literals: `SplitChoices = '${fsID}'` But even then this line won't work, because you're either trying to filter the wrong featureset, or you use the wrong query. fs doesn't have a field SplitChoices, and if you want to query rent_amount, you should use LIKE: `rent_amount LIKE '%${fsID}%'` Also, GroupBy doesn't change the input featureset, but returns a new one, so you have to store the result in a variable (line 22). I couldn't really make sense of your attempted join, but I think you are trying to achieve something like this: // Reference layer using the FeatureSetByPortalItem() function.
var fs = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '288db7f54ea048c5b6241f156ef0f646' , 0, ['*'], true);
var outputDict = {
fields: [
{ name: "rent_amount", type: "esriFieldTypeString" },
{ name: "address", type: "esriFieldTypeString" },
{ name: "landlord", type: "esriFieldTypeString" },
],
geometryType: "esriGeometryPoint",
features: []};
var i = 0;
// iterate over the input features
for (var f in fs) {
// split the rent field
var rentSplit = Split(f["rent_amount"], ",")
// iterate over the rent amounts
for(var r in rentSplit) {
// append a new output feature with the input feature's attributes and the current rent amount
outputDict.features[i++] = {
attributes: {
rent_amount: rentSplit[r],
address: f["address"],
landlord: f["landlord"]
},
geometry: Geometry(f)
}
}
}
return FeatureSet(Text(outputDict));
... View more
02-20-2023
11:06 PM
|
0
|
6
|
4858
|
|
POST
|
You can use the Split edit tool to split features with other features. Here, I'm splitting 4 polygons by 3 polylines: Result: This changes the polygon feature class, be sure to backup your data!
... View more
02-20-2023
05:46 AM
|
0
|
0
|
1670
|
|
POST
|
I have run into the same problem in the past. The way I dealt with this is defining an empty class in the toolbox. You can set and get class attributes for this class in the tool methods. class Toolbox:
def __init__(self):
self.label = "Toolbox"
self.alias = "toolbox"
self.tools = [Tool]
class ToolboxData:
pass
class Tool:
def __init__(self):
self.label = "Tool"
self.canRunInBackground = False
def getParameterInfo(self):
version_param = arcpy.Parameter(
displayName="Version",
name="version",
datatype="GPString",
parameterType="Optional",
direction="Input")
version_param.value = "testing, testing, 123 ..."
ToolboxData.version = 100
return [version_param]
def execute(self, parameters, messages):
arcpy.AddMessage("execute: " + str(ToolboxData.version))
... View more
02-20-2023
01:30 AM
|
0
|
1
|
4823
|
| 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
|