|
POST
|
the filter statement in the Filter() function has to be a valid SQL statement. You're using "status = in service", which is invalid, because status seems to be a text field, so the text value should be enclosed in single quotes. You shouldn't need to call Sum(). Length(featureset) already returns a single numeric value. Try this: var WatPipe = Filter(FeaturesetByName($datastore, 'WAT_Pipes', ['*']), "status = 'in service'")
var Pipewithin = Contains($feature, WatPipe)
return Length(Pipewithin)
... View more
03-03-2023
02:01 PM
|
3
|
1
|
12837
|
|
POST
|
You could use the Calculate Field tool. Switch language to Arcade, use this expression (edit the 2nd line to load your line feature class) // load the line feature class
var lines = FeaturesetByName($datastore, "LineFC")
// create a buffer aroun d the current point
var p_buffer = Buffer($feature, 10, "meters")
// get all lines intersecting that buffer
var i_lines = Intersects(p_buffer, lines)
// check the count and return the correct result
var c = Count(i_lines)
return IIf(c > 0, "1", "NULL")
... View more
03-03-2023
01:51 PM
|
1
|
0
|
1876
|
|
IDEA
|
@DavidNyenhuis1 , @Anonymous User Any news on this isssue? I just answered another question about this and got curious. Here are some questions I found in a very cursory search where converting the Date() to Number() was the solution, I probably missed a few. Arcade script to split multi pick field values - Esri Community ArcGIS Dashboard Using Arcade to union two dataset... - Esri Community Solved: Help getting a data expression to work. - Esri Community Solved: Arcade Expression: No values returned by FeatureSe... - Esri Community Solved: Arcade dictionary to FeatureSet - Esri Community Solved: How to maintain date data in arcade expressions - Esri Community Arcade FeatureSets and Date Fields: What's Going O... - Esri Community Solved: esriFieldTypeDate in Data Expression in Dashboard ... - Esri Community Solved: Arcade Data Expressions with Date Column Not Worki... - Esri Community Solved: Date fields in data expressions for serial charts - Esri Community Solved: Feature not being created due to date field type - Esri Community Solved: Arcade Data Expression- Dictionary from multiple t... - Esri Community Solved: Pass values to new columns Arcade - Esri Community Solved: Re: Arcade - How to use a date field with a dictio... - Esri Community There are probably many users who have the same problem but didn't ask a question (I know I was). They either got the solution from an already solved question (good: they got a solution, bad: they had this easily avoidable problem in the first place) or they couldn't solve this problem and moved on (obviously bad).
... View more
03-01-2023
11:14 PM
|
0
|
0
|
6428
|
|
POST
|
To post code: Sadly, fields with type esriFieldTypeDate don't expect dates, but numbers. So you have to convert first: feat = {
'attributes': {
'split_choices': Trim(split_array[i]),
'_date': Number(vfeature._date)
}
} This is a behavior that confuses a lot of users. I'm trying to get it fixed, please give your kudo to this idea: Arcade: Allow Date() values in date fields (esriFi... - Esri Community
... View more
03-01-2023
09:59 PM
|
1
|
1
|
3154
|
|
POST
|
The problem is that the Dashboard can only filter by equality: rental_amount_layer = rental_amount_selector But if you select "$500-$600", the dashboard can't find features to show, because the values in the layer are built like "$500-$600,$600-$800,$1000-$1100". What you need is a LIKE filter, which doesn't seem to exist in Dashboard. So, you've got (at least) two options: If you have to use Dashboard, you need to reconfigure your layer to only show the separate rental amounts (many points at the same location). This way, you can even skip the data expression and build the category selector based on the layer. If you don't have to use Dashboard, you can easily achieve this with an Experience. Add your map and a Filter widget, set the filter query to "Rent Amount - includes - predefined values", and define some categories. And then you can select the amounts you want to filter:
... View more
02-28-2023
11:55 PM
|
0
|
0
|
4783
|
|
POST
|
To get the average of a featureset column , we can use the Average() function. Let's load some test data: // create a test fs for a scoring survey.
// 3 text fields with scores between 1 and 5
var survey_dict = {
fields:[
{name: "Score1", type: "esriFieldTypeString"},
{name: "Score2", type: "esriFieldTypeString"},
{name: "Score3", type: "esriFieldTypeString"},
],
geometryType: "",
features: []
}
for(var i = 0; i < 200; i++) {
var rating = {attributes: {
Score1: Text(Round(4 * Random() + 1)),
Score2: Text(Round(4 * Random() + 1)),
Score3: Text(Round(4 * Random() + 1)),
}}
Push(survey_dict.features, rating)
}
var survey = Featureset(Text(survey_dict))
// return survey Now, if we take the Average() of column Score1, we get this result: This is obviously incorrect. It seems like the function doesn't convert to Number(), but instead somehow uses the bytes of the string values as number (or something else...). So we need to covert that column to a proper integer column first. I haven't found a way to do that inside the Average() function, so we should probably just convert the featureset before calling Average(): var score_fields = ["Score1", "Score2", "Score3"]
// create an empty featureset dict
var numeric_survey_dict = {
fields: [],
geometryType: "",
features: []
}
// add the score fields as integer fields
for(var i in score_fields) {
var field = {name: score_fields[i], type: "esriFieldTypeInteger"}
Push(numeric_survey_dict.fields, field)
}
// go thorugh the original featureset and convert each value to Number()
for(var f in survey) {
var converted_f = Dictionary()
for(var i in score_fields) {
var field = score_fields[i]
converted_f[field] = Number(f[field])
}
Push(numeric_survey_dict.features, {attributes: converted_f})
}
// convert the dictionary to a featureset
var numeric_survey = Featureset(Text(numeric_survey_dict))
// get the Average()
return Average(numeric_survey, "Score1")
... View more
02-28-2023
05:09 AM
|
0
|
0
|
2712
|
|
POST
|
which means I have to go in and remove all the extraneous stuff . For that, I just use the block quotes... Personally, it doesn't bother me that much, because I often have to expand the toolbar anyway to get to the code button...
... View more
02-28-2023
12:45 AM
|
1
|
0
|
1762
|
|
POST
|
You're using an alias as join field ("Mapunit key"), that might be the problem. Try with the actual field name. If you can run it from the tool, then go to the geoprocessing history, right-click on the successfull tool run, send the code to the Python Window, and analyze the command.
... View more
02-28-2023
12:34 AM
|
3
|
2
|
3089
|
|
POST
|
You can't really undo it if it happened that long ago. You can only recreate the deleted features by copying from a backup of your feature class or from the original data. If your feature class is versioned, you can add the archive to the map and get the historic features from there. If you made manual backups of your data, you could go back to a backup before the split and copy the missing features to your current feature class. If you're working on a network drive, you can talk to your IT department, they might be doing automatic backups. If none nof these apply, you're probably out of luck and have to redo your whole workflow for the deleted polygons.
... View more
02-28-2023
12:19 AM
|
0
|
0
|
1280
|
|
IDEA
|
This is a duplicate of this idea: Definition Query Icon in Table of Contents - Esri Community It's currently closed, but there is a lot of discussion going on. Be sure to look through the dicussion to see an explanation of why this is currently not implemented. In the meantime, there is a filter for the table of contents: @KoryKramer
... View more
02-28-2023
12:07 AM
|
0
|
0
|
2733
|
|
POST
|
Inside the category filter, don't use the "Features" option. You need the "Grouped Values" option and group by rent_amount, which should give you distinct values.
... View more
02-27-2023
11:37 PM
|
0
|
2
|
4797
|
|
POST
|
1 Mb / 1000 rows / 1000 columns = 0.000001 Mb / Cell 0.000001 Mb = 1 Byte In 1 Byte (8 bit) of data you can store one of 256 (2^8) integer values (0 ... 255 or -128 ... 127). Of course, that's the size for the pure raster cell values. In a "real" raster format (say ESRI's ASCII raster format), you would have separators between the values in one row (space), separators between the rows (linebreak), and header data (cell size, start coordinates), so the raster size would be somewhat above 1 Mb.
... View more
02-27-2023
04:41 AM
|
0
|
0
|
1279
|
|
POST
|
but I need to change the IsBusStop field based on whether or not "LOADING ZONE" is found in the description field. Yes, but if the IsBusStop field can only have the values "Y" and "N", then you don't actually need to replace that value, you can just set it. but I need to change the IsBusStop field based on whether or not "LOADING ZONE" is found in the description field. That's because you use another expression. Try it with the expression that actually worked.
... View more
02-24-2023
12:12 AM
|
1
|
0
|
1532
|
|
POST
|
Phew, turns out to be more complicated than I expected. Or there is some simple solution I overlooked... fc = "TestPoints"
# get a near table with all pairs
near_table = arcpy.analysis.GenerateNearTable("TestPoints", "TestPoints", r"memory/NearTable", closest="ALL")
# extract the rank 1 pairs
rank_1 = [row
for row in arcpy.da.SearchCursor(near_table, ["IN_FID", "NEAR_FID"], "NEAR_RANK = 1")
]
# save these connections for later
feature_connections = list(rank_1)
# find the clusters of those pairs
clusters = []
while len(rank_1) > 0:
cluster = set() # new empty cluster
test_fids= set(rank_1[0]) # start with the first available fid pair
while len(test_fids) > 0:
cluster.update(test_fids) # add all test_fids to the cluster
# find the next test_fids
# all fid pairs where either fid is in the current_fids
# and not already in the cluster
next_fids = set()
for r in rank_1:
if r[0] in test_fids or r[1] in test_fids:
next_fids.update(set(r))
test_fids = next_fids.difference(cluster)
clusters.append(cluster)
# remove all fid pairs of this cluster from the fid pair list
rank_1 = [r
for r in rank_1
if r[0] not in cluster and r[1] not in cluster
]
print("Detected the following clusters:")
print(clusters)
# get the cluster connections
cluster_connections = []
for cluster in clusters:
start = set(cluster)
not_stop = set(cluster)
while True:
# find nearest point in another cluster
where = f"IN_FID IN {tuple(start)} AND NEAR_FID NOT IN {tuple(not_stop)}"
sql = (None, "ORDER BY NEAR_DIST")
with arcpy.da.SearchCursor(near_table, ["IN_FID", "NEAR_FID"], where, sql_clause=sql) as cursor:
for connection in cursor:
break
# if the reverse connection already exists, get the second nearest
# cluster, else you could get "super cluster" of clusters that are
# each other's closest clusters
rev_connection = tuple(reversed(connection))
if rev_connection in cluster_connections:
other_cluster = [c for c in clusters if connection[1] in c][0]
not_stop.update(other_cluster)
# if the connection does not yet exist, we're done
else:
cluster_connections.append(connection)
break
print("Detected the following connections between clusters:")
print(cluster_connections)
# put all the connections together
unique_feature_connections = []
for connection in feature_connections:
if tuple(reversed(connection)) not in unique_feature_connections:
unique_feature_connections.append(connection)
connections = unique_feature_connections + cluster_connections
print("\n\nDetected the following connections between the features:")
print(connections) Input (points, but it should work with any geometry type): Connections generated from a simple Generate Near Table: And the result of my script with connections between the clusters: There are some cluster connections that aren't really necessary, for example between points 161/166, or 156/163. Sadly, you can't just connect to the closest cluster, because then you could get "super clusters" of clusters that are each other's closest clusters, for example the two clusters in the lower left. That's why I look for the second closest cluster if I detect a cluster connection multiple times. The "correct" way would be to check if the cluster is connected to the greater network of clusters and if so skip the detection of a new cluster connection, but I'm too lazy to figure out a proper solution for that...
... View more
02-23-2023
11:56 AM
|
2
|
0
|
2564
|
|
POST
|
Related Idea trying to get this fixed: Arcade: Allow Date() values in date fields (esriFi... - Esri Community
... View more
02-23-2023
04:17 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
|