|
POST
|
Sorry, I forgot to answer yesterday... does all of the required data need to live within the same project/map service or can the code work with other layers that already exist on our enterprise server? The data has to be in the same datastore for the FeaturesetByName() function. If you have data in your Portal, you can use that with the FeaturesetByPortalItem() function. The arcade code can't find the name of the feature? There's a space in the name ("Feature X"), which is not allowed for feature classes. You're probably trying to input the feature class's alias. You have to use the actual name. I have a field in the point feature class with the same name as the field that I'm looking up in the other layer. I specified this field when creating the expression but do you need to specify it in the code? Yes. The f.Field in my sample expressions was meant as a placeholder for the actual field names. rather than intersecting I need to use 'contains within'. It doesn't work that way around, which is also why you get null. This is the signature of Contains(): Contains(containerGeometry, insideFeatures) It expects a geometry or feature as first argument and a featureset as second argument. You're supplying a featureset (the polygons) as first argument and a feature (the point) as second. And even if you do it the right way, it won't return any results, because a point can't contain a polygon. You have to use Intersects(), which is OK, because if a polygon contains a point, that point will intersect the polygon. Therefore the query will need to be something like - when a point is created in this particular polygon look up these 2 values - the name of the person who is responsible for the polygon & the polygon area name. These 2 values will the populate the fields in the point class. So the rule would look like this (mashup of my two previous examples, with more descriptive variable names) // field for the rule: empty
// load the polygon feature class
var polygons = FeaturesetByName($datastore, "NameOfThePolygonFeatureClass")
// get the first polygon that intersects this point
var i_polygon = First(Intersects(polygons, $feature))
// get the responsible person
var person = Iif(i_polygon == null, null, i_polygon.ResponsiblePeron)
// get the polygon's name
var name = Iif(i_polygon == null, null, i_polygon.PolygonName)
// return
return {
result: {attributes: {
ResponsiblePerson: person,
PolygonName: name
}}
} Things you have to change: name (not alias!) of the polygon feature class, line 5 field name (not alias!) for the person in the polygon fc (line 11) and the point fc (line 19) field name (not alias!) for the polygon's name (lines 14 and 20)
... View more
01-18-2023
02:11 AM
|
0
|
0
|
2227
|
|
POST
|
I have no clue about utility services. Is this the structure you're trying to achieve? Are the laterals in the same feature class as the water lines? Do you have relationships between water lines / valves / laterals / plugs based on attributes? Or do you just care about geometry?
... View more
01-18-2023
01:21 AM
|
1
|
1
|
2401
|
|
IDEA
|
Yeah, you could do something like that with Attribute Rules. As Bud said, create a flag field. Let's make it a text field called "Locked". If its value is "Yes", all edits should be forbidden. If its value is anything else, edits go through. You can do a simple Constraint Attribute Rule return !($feature.Locked == "Yes" && $originalfeature.Locked == "Yes") This will return false (block the edit) if the lock field is and was enabled. This way, you can edit the lock field's value. This works great for manual edits, as it throws an error in you face, telling you why the edit was blocked: But it also throws that error for automated edits, which is bad, because the script/tool will stop at the first locked feature. You can do a Calculation Attribute Rule // field: empty
// triggers: Update
// if the feature is locked, use the old values, else use the new values
var locked = $feature.Locked == "Yes" && $originalfeature.Locked == "Yes"
var feat = IIf(locked, $originalfeature, $feature)
// create and fill the result dictionary
var result = {geometry: Geometry(feat), attributes: {}}
var fields = Schema($feature).fields
for(var f in fields) {
var field = fields[f]
if(!field.editable) { continue }
result.attributes[field.name] = feat[field.name]
}
// return
return {result: result} This rule will just silently use the original values if you try to override a locked feature's values. This is good for automated editing, because the script/tool won't error out on locked features. It might be a little confusing for manual editors...
... View more
01-18-2023
12:58 AM
|
0
|
0
|
991
|
|
POST
|
Does this do what you want? var prefix = $feature.CASTERBOXCARDBOARD_PREFIX
var week = IIf(
IsEmpty($feature.CASTERBOXCARDBOARD_WEEK),
"",
Left($feature.CASTERBOXCARDBOARD_WEEK, 1)
)
var route_length = 5 - Count(prefix) - Count(week)
var route = Right($feature.CASTERBOXCARDBOARD_ROUTE, route_length)
return Concatenate([prefix, route, week])
... View more
01-17-2023
11:12 PM
|
0
|
7
|
3385
|
|
POST
|
So, as you discovered, if a point is within a polygon, NEAR_DIST will be zero. There's no way to switch to centroid in the Near tool. You have to do an extra step: Use Feature To Point (Data Management)—ArcGIS Pro | Documentation to get the centroids of the polygons. Then run the Near tool with these centroids. While this results in NEAR_DIST > 0, it loses the relationship to the polygons, because NEAR_FID uses the ObjectID of the centroids and you can't switch that to ORIG_FID (the ObjectID of the polygons). If you need the OBJECTIDs of the polygons, you have to use Join Field (Data Management)—ArcGIS Pro | Documentation, joining Centroids.ORIG_FID to the station fc with the relation Centroids.OBJECTID = stations.NEAR_FID
... View more
01-17-2023
10:58 PM
|
1
|
0
|
2019
|
|
POST
|
Set messaging to None. The deletion happens because it is a composite relationship, regardless of messaging. The messaging takes care of updating geometry (automatic in a composite relationship) and attributes (has to be programmed). To read deeper into relationship class properties: Relationship class properties—ArcGIS Pro | Documentation
... View more
01-17-2023
10:34 PM
|
0
|
0
|
1374
|
|
POST
|
Are your amenity_fields correct? Capitalization is important here!
... View more
01-17-2023
08:24 AM
|
0
|
0
|
1134
|
|
POST
|
There are no Python Addins in ArcGIS Pro, and there are no plans to add them: Python Add-Ins for ArcGIS Pro - Page 8 - Esri Community Instead, Addins have to be built with the ArcGIS Pro SDK for .Net. Build your first add-in | Documentation | ArcGIS Developers With some luck, you can port the majority of your addin functionality into a Python toolbox. With that, you would have to same GUI as the normal ArcGIS geoprocessing tools. You may want to look into What is a Python toolbox?—ArcGIS Pro | Documentation . If you decide to go down that route, It's important to note that ArcMap uses Python 2.7, but ArcGIS Pro uses Python 3.X. There are some changes in the syntax, you can read more here: Python migration from 10.x to ArcGIS Pro—ArcGIS Pro | Documentation
... View more
01-17-2023
08:15 AM
|
1
|
1
|
3076
|
|
POST
|
To do that, you can use the tool Export Features (Conversion)—ArcGIS Pro | Documentation. The documentation of the ArcGIS Tools always has a section which tells you how to call the tool in Python: I don't know your data, but here are two quick examples: Just copy the whole feature class arcpy.conversion.ExportFeatures(
"C:/Data/OldGeodatabase.gdb/Buildings",
"C:/Data/NewGeodatabase.gdb/Buildings"
) Copy the features into different Featureclasses, depending on a field value in_features = "C:/Data/OldGeodatabase/Buildings"
classification_field = "Country"
# read all values of the classification field
class_values = []
with arcpy.da.SearchCursor(in_features, [classification_field]) as cursor:
for row in cursor:
class_values.append(row[0])
# often, you will find syntax like this:
# class_values = [row[0] for row in arcpy.da.SearchCursor(in_features, [classification_field])]
# this is called list comprehension, lots of good intros into that online.
# convert the list (all values) into a set (distinct values)
distinct_class_values = set(class_values)
# loop over the distinct values
for class_value in distinct_class_values:
print(class_value)
# create a SQL query that will filter for that value
query = f"{classification_field} = '{class_value}'" # this is called f-string
# export the filtered features into a new feature class
arcpy.converion.ExportFeatures(
in_features,
f"C:/Data/NewGeodatabase.gdb/{class_value}_Buildings",
query
)
... View more
01-17-2023
04:53 AM
|
2
|
0
|
959
|
|
POST
|
Yes, you're passing values. BUT: Your values are objects with attributes and methods. In your operate function, you're using these methods to change the internal attributes of your values. Here's what's happening: static void operate (StringBuffer x, StringBuffer y)
{
// x and y are passed by value. but they have internal values themselves.
// here, you're changing x's internal value. You're not changing x itself, only its internal value!
x.append(y);
// here, you're creating a new variable in the local scope of this function.
// this does not change the variable you passed into this function, because
// it is outside of this function's scope.
// IF you would be passing by reference (which you are not!), this would
// change the outer y
y = x;
}
public static void main (String [] args)
{
StringBuffer a = new StringBuffer ("A");
// a = "A"
StringBuffer b = new StringBuffer ("B");
// b = "B"
operate (a,b);
// a = "AB", because you changed a's internal value
// b = "B", because you didn't change its internal value
// y_inside_the_function = "AB", but y only exists inside the function's scope
System.out.println(a + "," +b);
// "AB,B"
} There are some good explanations in this StackOverflow post: methods - Is Java "pass-by-reference" or "pass-by-value"? - Stack Overflow
... View more
01-17-2023
02:56 AM
|
1
|
0
|
1782
|
|
POST
|
You're not calling the function in your main You get an infinite recursive loop, because you keep calling the function even if position < 0 import java.io.*;
public class Recursion {
public static void main(String[] args) throws IOException{
int myArray[] = {1,2,3,4,5,6,7,8,9,10};
reverseDisplay(myArray, 9);
}
public static void reverseDisplay(int[] ary, int position){
if(position > 0) {
System.out.print(ary[position]);
reverseDisplay(ary, position - 1);
}
}
}
... View more
01-17-2023
02:03 AM
|
1
|
0
|
1435
|
|
POST
|
As Dan said, there's no out of the box tool. If you need that functionality in Model Builder, you have to create that tool yourself. Below are two quick examples. You can save that script as a Python toolbox (.pyt), load that into ArcGIS Pro, and then drag the tools in to your model. # -*- coding: cp1252 -*-
import arcpy
class Toolbox(object):
def __init__(self):
self.label = "Utility"
self.alias = "utility"
self.tools = [InsertRow, InsertRowIntoTableA]
class InsertRow(object):
label="Insert Row"
description="Inserts a row into a table"
def getParameterInfo(self):
parameters = [
arcpy.Parameter(name="in_table", displayName="Table", datatype="DETable", parameterType="Required", direction="Input"),
arcpy.Parameter(name="row", displayName="Row", datatype="GPValueTable", parameterType="Required", direction="Input"),
arcpy.Parameter(name="out_table", displayName="Edited Table", datatype="DETable", parameterType="Derived", direction="Output"),
]
parameters[1].columns = [
["GPString", "Field"],
["GPString", "Value"]
]
return parameters
def updateParameters(self, parameters):
par = {p.name: p for p in parameters}
in_table = str(par["in_table"].value)
# reset fields if no table is selected
if in_table == "None":
par["row"].value = None
return
# get fields from the table
target_fields = [
f.name
for f in arcpy.ListFields(in_table)
if f.type not in ("OID", "GlobalID", "Geometry")
]
# get currently loaded fields
current_fields = []
if par["row"].value is not None:
current_fields = [
f
for f, v in par["row"].value
]
# if these don't match, a different table was selected -> change fields
if current_fields != target_fields:
par["row"].value = [[f, None] for f in target_fields]
def execute(self, parameters, messages):
par = {p.name: p for p in parameters}
# get fields with user input
row = [
[field, value]
for field, value in par["row"].value
if value not in ('', None)
]
fields, values = list(zip(*row))
# insert the new row
# all values are str, but the InsertCursor should take care of the conversion
with arcpy.da.InsertCursor(str(par["in_table"].value), fields) as cursor:
cursor.insertRow(values)
# set the output parameter
par["out_table"].value = par["in_table"].value
class InsertRowIntoTableA(object):
label="Insert Row into TableA"
description="Inserts a row into TableA"
def getParameterInfo(self):
parameters = [
arcpy.Parameter(name="in_table", displayName="TableA", datatype="DETable", parameterType="Required", direction="Input"),
arcpy.Parameter(name="ID_A", displayName="ID_A", datatype="GPLong", parameterType="Required", direction="Input"),
arcpy.Parameter(name="TEXT_A", displayName="TEXT_A", datatype="GPString", parameterType="Required", direction="Input"),
arcpy.Parameter(name="out_table", displayName="Edited TableA", datatype="DETable", parameterType="Derived", direction="Output"),
]
return parameters
def execute(self, parameters, messages):
par = {p.name: p for p in parameters}
# get the values
fields = ["ID_A", "TEXT_A"]
values = [
par[f].value
for f in fields
]
# insert the new row
with arcpy.da.InsertCursor(str(par["in_table"].value), fields) as cursor:
cursor.insertRow(values)
# set the output parameter
par["out_table"].value = par["in_table"].value
... View more
01-17-2023
01:47 AM
|
1
|
0
|
2061
|
|
POST
|
Create a database sequence: Create Database Sequence (Data Management)—ArcGIS Pro | Documentation Use this expression in the attribute rule: // Calculation Attribute Rule for the ID field
// triggers: Insert, Update
// Exclude from application evaluation
// If there is already a value in the ID field, return that
if(!IsEmpty($feature.AssetNumber)) {
return $feature.AssetNumber
}
// get all the parts for the unique id, format them correctly
var parts = [
$feature.RoadType,
Text($feature.Location, "00"),
Text($feature.Sublocation, "00"),
"-",
Text(NextSequenceValue("NameOfTheSequence"), "0000")
]
// concatenate and return
return Concatenate(parts, "")
... View more
01-16-2023
11:42 PM
|
2
|
1
|
1337
|
|
POST
|
There's a difference between a feature class and a layer. Very basically: the feature class is the actual data, the physical object being saved on your disc the feature layer is a representation of that data. Things like coordinate transformation, symbology, labeling, popups are done on the layer, not on the data. If you symbolize your layer, the underlying feature class doesn't know anything about that. Importantly, one other thing that only works on the layer, not on the feature class, is selection. You start out doing the right thing: Create a layer (klasse1_f1) of the data and do the selection on that layer. But then you copy the feature class (klasse1). The feature class has no selection, because you selected on your layer and there is no feedback to the feature class. So this should work as intended: arcpy.management.CopyFeatures(klasse1_f1, "siedlung") As a side note: you don't actually need to do the selection. You could just use your queries in the MakeFeatureLayer tool. This sets the definition query of the resulting layer. So you could do this: #Klassierung der Klasse1 (Siedlung)
klasse1_siedlung = arcpy.management.MakeFeatureLayer(klasse1, "klasse1_siedlung", "'CLC15' = '111'")
arcpy.management.CopyFeatures(klasse1_siedlung , "siedlung")
#Klassierung der Klasse1 (Industrie)
klasse1_industrie = arcpy.management.MakeFeatureLayer(klasse1, "klasse1_industrie ", "'CLC15' = '121' OR 'CLC15' = '131' OR 'CLC15' = '132' OR 'CLC15' = '133'")
# you could also write this as
# CLC15 IN ('121', '131', '132', '133')
arcpy.management.CopyFeatures(klasse1_industrie , "industrie")
... View more
01-15-2023
02:42 AM
|
1
|
1
|
5412
|
| 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
|