|
POST
|
Your problem is in the last line: You try to return the whole parent feature. Even if you only load one field (Namn), the feature still holds other information, such as geometry. You have to specify what field you want to return: return parent.Namn
... View more
01-12-2022
01:03 AM
|
0
|
8
|
4861
|
|
POST
|
Disclaimer: This is the first time I'm looking at Dashboard Serial Charts, it's possible I'm overlooking things here. 1.) If "Include" doesn't work, try chaining together multiple "Equals" with "Or". So instead of WHERE Field IN (Value1, Value2) you get Where Field = Value1 OR Field = Value2 2.) Doesn't seem doable. You probably have to create a new database view with all the lines, share it and build your chart from that.
... View more
01-11-2022
04:00 AM
|
1
|
1
|
3935
|
|
POST
|
AFAIK, anything that requires a "where_clause" (e.g. SelectLayerByAttribute or SearchCursor) can only apply to the target table. You can not use other tables in the query. So you have to do the sub query yourself: Open the Python window, copy this code and excute it. exclude_field = "My_ID"
exclude_table = "Geocoded_20210412"
select_table = "Geocoded_20201123"
# SELECT exclude_field FROM exclude_table
exclude_values = [row[0] for row in arcpy.da.SearchCursor(exclude_table, [exclude_field])]
# WHERE exclude_field NOT IN (1, 2, 3)
# WHERE exclude_field NOT IN ('a', 'b', 'c')
try:
if isinstance(exclude_values[0], str):
where = "{} NOT IN ('{}')".format(exclude_field, "', '".join(exclude_values))
else:
where = "{} NOT IN ({})".format(exclude_field, ", ".join([str(x) for x in exclude_values]))
except IndexError:
where = None
arcpy.management.SelectLayerByAttribute(select_table, 'NEW_SELECTION', where)
... View more
01-11-2022
03:09 AM
|
0
|
1
|
3169
|
|
POST
|
It's hard to understand what you want. Is it something like this? If not, can you give us more details and/or a sketch?
... View more
01-11-2022
01:56 AM
|
0
|
0
|
720
|
|
POST
|
For code display: Please move the "Insert code sample" button - Esri Community The count in PolygonsA changes when a feature is added in B a feature is updated in B a feature is deleted in B a feature is added in A a feature is updated in A For A, it's easy: // Calculation Attribute Rule in PolygonA (L16GridSystem15NM)
// field: RangeUsage
// triggers: insert, update
// if you want to get fancy, you can return early if neither the geometry
// nor the count field changed:
if(Equals(Geometry($feature), Geometry($originalfeature)) && $feature.RangeUsage == $originalfeature.RangeUsage) {
return $feature.RangeUsage
}
// return the count of intersecting features of PolygonsB
var fs_polygons_b = FeatureSetByName($datastore, "PolygonsB", ["GlobalID"], true)
var intersecting_b = Intersects($feature, fs_polygons_b)
return Count(intersecting_b) For PolygonsB it's a little more complicated. Basically, whenever a feature is added/updated/deleted in B, you want to trigger the calculation rule in the intersecting A features. In this example I do that by setting the count field to null. // Calculation Attriute Rule in PolygonsB
// field: empty
// triggers: insert, update, delete
var fs_polygons_a = FeatureSetByName($datastore, "PolygonsA", ["GlobalID"], true)
var updates = []
// update all A features that intersect the new or updated B feature
if(Includes(["INSERT", "UPDATE"], $editcontext.editType)) {
for(var a in Intersects($feature, fs_polygons_a)) {
Push(updates, {globalID: a.GlobalID, attributes: {RangeUsage: null}})
}
}
// update all A features that intersected the original feature (before update or deletion)
if(Includes(["UPDATE", "DELETE"], $editcontext.editType)) {
for(var a in Intersects($originalfeature, fs_polygons_a)) {
Push(updates, {globalID: a.GlobalID, attributes: {RangeUsage: null}})
}
}
return {
edit: [{className: "L16GridSystem15NM", updates: updates}]
} The rule for PolygonsB currently works for inserting and updating features. It does not work for deleting features, I have absolutely no idea why. Maybe someone else can shed light on that. Maybe @jcarlson ?
... View more
01-11-2022
01:33 AM
|
1
|
2
|
3169
|
|
POST
|
Seems like arcpy.ExecuteError has only two public attributes: args and with_traceback(). You probably won't get around parsing the string. try:
arcpy.management.Append(fc_wrong_schema, target_fc)
except arcpy.ExecuteError as e:
if "ERROR 000466" in e.args[0]:
# handle
print("DELETE FEATURE CLASS")
else:
# handle or raise
raise
except:
# handle or raise
pass
... View more
01-10-2022
01:46 AM
|
5
|
1
|
4144
|
|
POST
|
valuePrefix = "Q" + str(1) + str(22) + "_"
'"' + valuePrefix + "!OBJECTID!" + '"'
# '"Q122_!OBJECTID!"' That doesn't seem right. '"' + valuePrefix + '"' + " + str(!OBJECTID!)"
# '"Q122_" + str(!OBJECTID!)'
... View more
01-10-2022
12:53 AM
|
1
|
1
|
1752
|
|
POST
|
# CalculateField can be a little hard to understand, because you have to pass
# a string that evaluates to a correct Python expression. Biggest pitfall that
# I see on this forum is concatenating strings, because people get mixed up
# with the quotation marks of their expression and the quotation marks _around_
# the expression (that make it into a string).
# It's not clear from your question where quarter and year_2dig come from,
# chose the correct expression from below. Alo, note the double quotes inside
# the expression and the single quotes to turn the expression into a string.
# if quarter and year_2dig are fields in the table, this will result in
# '"Q{}{}_{}".format(!QUARTER!, !YEAR_2DIG!, !OBJECTID!)'
expression = '"Q{}{}_{}".format(!QUARTER!, !YEAR_2DIG!, !OBJECTID!)'
# if quarter and year_2dig are python variables, this will result in
# '"Q122_{}".format(!OBJECTID!)'
expression = '"Q{}{}_'.format(quarter, year_2dig) + '{}".format(!OBJECTID!)'
arcpy.CalculateField_management(loccode_fc, "QRTR_KEY", expression, "PYTHON_9.3", "")
... View more
01-10-2022
12:47 AM
|
1
|
0
|
1753
|
|
POST
|
It is absolutely possible. What you need to do: intersect boundaries and houses: this returns a point layer with addresses and boundary names intersect boundaries and stations: this returns a point layer with station names and boundary names use a way to connect the two layers using the common attribute boundary name A basic implementation of these steps in Python (assuming you work with ArcMap or ArcGIS Pro: open the Python window, paste and edit the code below, execute): # names of the 3 layers
boundary_layer = "Boundaries"
station_layer = "Stations"
house_layer = "Houses"
# names of the fields you want to extract
boundary_field = "BoundaryID"
station_field = "StationID"
house_field = "Address"
# intersect boundaries and stations
station_intersect = arcpy.analysis.Intersect([boundary_layer, station_layer], "memory/station_intersect")
# intersect boundaries and houses
house_intersect = arcpy.analysis.Intersect([boundary_layer, house_layer], "memory/house_intersect")
# read boundary data: [boundary_field]
boundaries = [row[0] for row in arcpy.da.SearchCursor(boundary_layer, [boundary_field])]
# read station data: [ [boundary_field, station_field] ]
stations = [row for row in arcpy.da.SearchCursor(station_intersect, [boundary_field, station_field])]
# read house data: [ [boundary_field, house_field] ]
houses = [row for row in arcpy.da.SearchCursor(house_intersect, [boundary_field, house_field])]
# connect station data and house data:
# {boundary_field: {"stations": [station_field], "houses": [house_field]}}
boundary_dict = {b: {"stations": [s[1] for s in stations if s[1] == b], "houses": [h[1] for h in houses if h[0] == b]} for b in boundaries}
import pprint
pprint.pprint(boundary_dict) If you want to extract the data for only a few boundries, select those boundaries before you run the code.
... View more
01-07-2022
04:17 AM
|
0
|
0
|
2977
|
|
POST
|
If you have a relationship class connecting the tables, then you can use FeaturesetByRelationshipName, which will give the same result as doing it manually (FeatureSetByName -> Filter). // get related rows by relationship name
// only if there is a relationship class defined between the tables
var mantenimientos = FeatureSetByRelationshipName($feature, "RelationShipName") If you have no relationship classes and can't use $datastore, you have to publish all tables. Then you can use one of the other FeatureSetBy* functions (especially FeatureSetByPortalItem): https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyid
... View more
01-05-2022
10:35 PM
|
0
|
0
|
3964
|
|
POST
|
Some other people will be more qualified to answer that in detail. My tips: make sure you hide sensitive information publish from a connection with only read access if there is sensitive data left, don't share publicly The first two points can be achieved by defining database views (CreateDatabaseView) and sharing those instead of the raw tables. Views can only be read, not written to, and you can hide sensitive or unnneccesary fields.
... View more
01-05-2022
10:16 PM
|
0
|
1
|
1848
|
|
POST
|
You can publish layers from your SDE, too. So either publish new layers from your SDE and use them in the dashboard, or go to the project from where you published the existing layers, change all data sources to the SDE and overwrite the published layers
... View more
01-05-2022
05:29 AM
|
1
|
3
|
1860
|
|
POST
|
For completeness, here's the doc for ArcMap: https://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/calculate-field.htm
... View more
01-05-2022
05:21 AM
|
0
|
0
|
10600
|
|
POST
|
You can find the documentation for the tool here: https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/calculate-field.htm CalculateField has the following signature: arcpy.management.CalculateField(in_table, field, expression, {expression_type}, {code_block}, {field_type}, {enforce_domains}) expression_type is an optional argument specifying the language you want to use (Python, Arcade, SQL), with Python being the default. Now here is where it gets fishy: You said you were working with ArcGIS Pro, but the error you got says you are using VB as the language for CalculateField. This would make sense, as VB is the default value for CalculateField in ArcMap (which also uses Python 2.7, while Pro uses Python 3). Something doesn't check quite out... There are some other problematic things with your code: your in_features seem to be in a file geodatabase (gdb), but you still specified the .shp extension. don't know if that will cause an error (I hope it will). the docs (see link above) specify that for Python code, you should enclose field names with !, you use '! the expression is given as a string, and your Python expression will be wrong, as you didn't enclose it in quotes. Try using this: inFeatures = r"H:\Python Projects\PycharmProjects\ArcPy\Test_Output\Trial_out.gdb\Trail_Data_A" # removed the .shp
expr_1 = "!AttArt_Ken!.split('_')[0]" # note the enclosing "
expr_2 = "!AttArt_Ken!.split('_')[-1]" # note the enclosing "
# for ArcMap & Python 2.7
arcpy.CalculateField_management(inFeatures, 'ObjArt_Ken', expr_1, "PYTHON")
arcpy.CalculateField_management(inFeatures, 'Wert', expr_2, "PYTHON")
# for ArcGIS Pro and Python 3:
arcpy.CalculateField_management(inFeatures, 'ObjArt_Ken', expr_1, "PYTHON3")
arcpy.CalculateField_management(inFeatures, 'Wert', expr_2, "PYTHON3")
... View more
01-05-2022
05:19 AM
|
2
|
1
|
10600
|
|
POST
|
You have to do a final GroupBy on layersDict to get the sum of all counts. // do a final GroupBy to add all reports in each province
var layers_fs = FeatureSet(Text(layersDict))
return GroupBy(
layers_fs,
['provinces'],
{name: 'TotalReportCount', expression: 'count_of_ids', statistic: 'SUM'}
)
... View more
01-05-2022
01:29 AM
|
1
|
1
|
1323
|
| 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
|