|
POST
|
Hmm, the tool worked for me... Try constructing the lines yourself: edit the input and output parameters of this script and run it in the python window. import logging
# define input data
in_table = "H:/testCruise_data_DDS.csv"
field_x = "Long"
field_y = "Lat"
field_distance = "distance"
field_bearing = "bearing"
wkid = 4326 # wkid of your data's coordinate system
# define output data
out_path = "memory"
out_name = "test"
out_fields = [ # list of [field_name, field_type]
["PLOT_ID", "LONG"],
["TYPE", "TEXT"],
["slope", "FLOAT"],
["bearing", "FLOAT"],
["Long", "FLOAT"],
["Lat", "FLOAT"],
]
# read data
fields = [f.name for f in arcpy.ListFields(in_table)]
data = [dict(zip(fields, row)) for row in arcpy.da.SearchCursor(in_table, fields)]
# construct lines
spatial_reference = arcpy.SpatialReference(wkid)
for d in data:
try:
point = arcpy.Point(d[field_x], d[field_y])
point_geometry = arcpy.PointGeometry(point, spatial_reference)
target_geometry = point_geometry.pointFromAngleAndDistance(d[field_bearing], d[field_distance])
point_array = arcpy.Array([point_geometry.firstPoint, target_geometry.firstPoint])
line_geometry = arcpy.Polyline(point_array, spatial_reference)
d["SHAPE@"] = line_geometry
except: # e.g. bearing or distance are empty
logging.exception("Could not create line for this row: {}".format(d))
d["SHAPE@"] = None
# create output fc
# skip this if you already have a line fc that you want to append to
out_fc = arcpy.management.CreateFeatureclass(out_path, out_name, "POLYLINE", spatial_reference=spatial_reference)
for f in out_fields:
arcpy.management.AddField(out_fc, f[0], f[1])
# write the lines into out_fc
fields = ["SHAPE@"] + [f[0] for f in out_fields]
with arcpy.da.InsertCursor(out_fc, fields) as cursor:
for d in data:
values = [d[f] for f in fields]
cursor.insertRow(values)
... View more
08-30-2021
12:09 AM
|
0
|
0
|
2713
|
|
POST
|
Sure. Load the related tables at the start of the script. In your loop, get the INT_Doc_ID and filter those tables. var tbl = FeatureSetByName($datastore,"ActivityClass");
var tbl_subjectitem = FeatureSetByName($datastore, "SubjectItem");
var tbl_contact = FeatureSetByName($datastore, "Contact");
var codigo = $feature["PI_ID"];
//var sql = "PI_ID= '" + codigo + "'";
// Arcade has a shortcut for constructing SQL queries that will take care of the type-relevant stuff (like apostrophes):
var sql = "PI_ID = @codigo";
Console(sql);
var mantenimientos = Filter(tbl, sql);
var cnt = Count(mantenimientos);
var historia = "";
if (cnt > 0) {
historia = cnt + " Record(s):";
for (var mantenimiento in mantenimientos) {
// ...
var doc_id = mantenimiento.INT_DOC_ID
var subjectitems = Filter(tbl_subjectitem, "INT_DOC_ID = @doc_id")
for(var si in subjectitems) {
// ...
}
var contacts = Filter(tbl_contact, "INT_DOC_ID = @doc_id")
for(var c in contacts) {
// ...
}
}
}
else {
historia = "No Records";
}
return historia;
... View more
08-26-2021
03:50 AM
|
0
|
5
|
4296
|
|
POST
|
You have more or less exhausted the popup's capabilities. The next step would be to return HTML: <a href="https://website.com/link1.pdf">Plan 1</a> You don't have to try that; it won't work, as HTML returned by an expression is encoded and thus won't be evaluated. One possible soultion to this: Figure out a maximum of plans you will have to return. For each plan, create an expression for the name and an expression for the hyperlink: // Which hyperlink will be returned? Start with 1, increase for each subsequent expression
var index = 1
// get hyperlinks of intersecting plan features
var plans = Intersects($feature, FeatureSetByName($datastore,"Plan Area", ["Hyperlink"], true))
// no intersecting plans or you already returned all hyperlinks in previous expressions
if(plans == null || Count(plans) < index) {
return ""
}
// return the specified hyperlink
var i = 1
for(var p in plans) {
if(i == index) {
return p.Hyperlink
}
i += 1
} // Which name will be returned? Start with 1, increase for each subsequent expression
var index = 1
// get names of intersecting plan features
var plans = Intersects($feature, FeatureSetByName($datastore,"Plan Area", ["PlanName"], true))
// no intersecting plans or you already returned all names in previous expressions
if(plans == null || Count(plans) < index) {
return ""
}
// return the specified name
var i = 1
for(var p in plans) {
if(i == index) {
return p.PlanName
}
i += 1
} Configure your popup, switch to HTML source and put in your links: <a href="{expression/plan_link_1}" target="_blank">{expression/plan_name_1}</a><br/>
<a href="{expression/plan_link_2}" target="_blank">{expression/plan_name_2}</a><br/>
<a href="{expression/plan_link_3}" target="_blank">{expression/plan_name_3}</a><br/>
<!-- and so on --> You could make it simpler by just doing the hyperlink expressions and returning them in the popup's attribute table, they should be formatted as links, I think. You won't have the plan names, though.
... View more
08-26-2021
03:28 AM
|
1
|
1
|
4583
|
|
POST
|
In my experience, the Field Calculator is not a good tool for sequential calculations. For one, you can never be quite sure about the order in which the fields are calculated. And second, while it's easy to get the previous row's value, I have no idea how to get the next row. This is a job for pure Python. Just edit this script and run it in the Python Window: fc = "gewaesserkataster_sde.GWK_SDE_ADMIN.nullable"
fields = ["ObjectID", "SHAPE@", "StartX", "StartY", "EndX", "EndY"] # first field determines the order the rows are calculated in!
# read the rows
data = [list(row) for row in arcpy.da.SearchCursor(fc, fields)]
data.sort(key=lambda d: d[0])
# calculate
for i in range(len(data)):
shp = data[i][1].firstPoint
data[i][2] = shp.X
data[i][3] = shp.Y
try:
next_shp = data[i+1][1].firstPoint
data[i][4] = next_shp.X
data[i][5] = next_shp.Y
except IndexError: # last row doesn't have next_shp
data[i][4] = None
data[i][5] = None
# write
data = {d[0]: d for d in data}
with arcpy.da.UpdateCursor(fc, fields) as cursor:
for row in cursor:
d = data[row[0]]
cursor.updateRow(d)
... View more
08-26-2021
02:44 AM
|
0
|
0
|
1124
|
|
POST
|
The expression uses the Includes() function, which is only available since Arcade 1.12 with ArcGIS Enterprise Server 10.9 You can do it the "old" way, which is more cumbersome: // Assigned To: ElectricDevice
// Type: Constraint
// Name: ElectricDevice - Transformer kVA
// Description: Validates that the features kVA is valid based on the type of transformer
// Subtypes: All
// Error Number: 5702
// Error Message: Feature kVA is not valid
// Trigger: Insert, Update
// Exclude From Client: False
// Disable: False
// Related Rules: Some rules rely on additional rules for execution. If this rule works in conjunction with another, they are listed below:
// - None
// Duplicated in: This rule may be implemented on other classes, they are listed here to aid you in adjusting those rules when a code change is required.
// - None
// ************* User Variables *************
// This section has the functions and variables that need to be adjusted based on your implementation
// 38 - Medium Voltage Transformer
// 39 - Medium Voltage Step Transformer
var valid_asset_groups = [38, 39];
var kva = $feature.ratedpower;
// ************* End User Variables Section *************
// ************* Functions *************
function asset_type_to_kva(id) {
return Decode(id,
782, [5000, 10000, 15000, 25000, 37500, 50000],
783, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
785, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
788, [30000, 45000, 75000, 112500, 150000, 225000, 300000],
789, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000],
792, [45000, 75000, 112500, 150000, 225000, 300000, 500000, 750000, 1000000, 1500000, 2000000, 2500000, 3000000, 3750000, 5000000, 7000000, 7500000, 10000000],
793, [25000, 37500, 50000, 75000, 100000, 167000],
794, [150000, 225000, 300000, 500000, 750000, 2500000],
801, [5000, 10000, 15000, 25000, 37500, 50000, 75000, 100000, 167000, 250000, 333000, 500000],
null)
}
// ************* End Functions *************
if (IsEmpty(kva)){
return true;
}
//if (!Includes(valid_asset_groups, $feature.assetgroup)) {
// return true;
//}
for (var i in valid_asset_groups) {
if(valid_asset_groups[i] == $feature.assetgroup) {
return true;
}
}
// Find the valid values, if an entry was not found, null is returned
var valid_kva = asset_type_to_kva($feature.assettype);
if (IsEmpty(valid_kva)) {
return true;
}
//return Includes(valid_kva, kva)
for (var i in valid_kva) {
if (valid_kva[i] == kva) {
return true;
}
}
return false;
... View more
08-26-2021
02:01 AM
|
0
|
1
|
1543
|
|
POST
|
Can you please provide an example table (snippet) and the result you want to create?
... View more
08-26-2021
01:32 AM
|
0
|
5
|
10880
|
|
POST
|
Do you actually have a database sequence called "MQT-C05"? https://pro.arcgis.com/de/pro-app/latest/tool-reference/data-management/create-database-sequence.htm
... View more
08-25-2021
01:32 AM
|
0
|
1
|
3287
|
|
POST
|
The URL doesn't change, but the token ("hosted" in your script) does. Try removing the token part. In my case, that leads to the following behavior: When I first open a popup containing an image, the image is broken, but the link still works. I click on the broken image link, the image opens. Every other popup containing an image now works as expected.
... View more
08-25-2021
01:07 AM
|
0
|
0
|
1514
|
|
POST
|
Yes, you will have to create different database sequences. Then you can do something like this: var polygons = FeatureSetByName($datastore, "polygons", ["Name"], true)
var polygon = First(Intersects(polygons, $feature))
if(polygon == null) {
return null
}
if(polygon.Name == "A") {
return "A" + NextSequenceValue("SequenceA")
}
if(polygon.Name == "B") {
return "B" + NextSequenceValue("SequenceB")
}
return null
... View more
08-24-2021
12:44 PM
|
1
|
3
|
3300
|
|
POST
|
Yes, it's because of the Update trigger. You can edit your values manually by putting something like this at the top of your rule: // If there already is a value in $feature.Field, just return that value (essentially change nothing).
// That allows you to put some other values in there.
// If you want to reset the value to be automatically calculated, just delete it (set it to null), the update rule will trigger.
if(!IsEmpty($feature.Field)) {
return $feature.Field
}
// your code goes here
... View more
08-24-2021
08:38 AM
|
2
|
1
|
4155
|
|
POST
|
So you create a feature inside a school district (polygon) and want to return the name of the next district within 1 mile that is not the district the feature is in. Did I get that right? var school_districts = FeatureSetByName($datastore, "SCHOOL_DIST", ["NAME"], true);
var search_radius = Buffer($feature, 1, "Mile")
var districts_within_search_radius = Intersects(school_districts, search_radius)
// no districts around the feature
if(Count(districts_within_search_radius ) == 0) {
return "feature has no school district within search radius"
}
// this is basically the code from your previous question
var min_distance = Infinity
var nearest_district = ""
for(var district in districts_within_search_radius) {
var dist = Distance($feature, district)
// dist > 0: exclude the district that contains the feature
if(dist > 0 && dist < min_distance) {
min_distance = dist
nearest_district = district.NAME
}
}
// no districts that don't intersect the feature
if(nearest_district == "") {
return "there are " + Count(districts_within_search_radius) + " districts within the search radius, but they all intersect the feature"
}
return nearest_district
... View more
08-24-2021
07:43 AM
|
1
|
1
|
1114
|
|
POST
|
Sure. Same as this rule, but return MINDISTANCE instead of NEARESTSCHOOL.
... View more
08-20-2021
07:09 AM
|
0
|
1
|
2566
|
|
POST
|
var CURRENTSCHOOLS = FeatureSetByName($datastore, "ELEMENTARY_SCHOOL", ["School_Nam"]);
VAR SEARCHDISTANCE = 10;
VAR SCHOOLINTERSECT = INTERSECTS(CURRENTSCHOOLS, BUFFER($FEATURE, SEARCHDISTANCE, "MILES"))
IF(SCHOOLINTERSECT == null || COUNT(SCHOOLINTERSECT) == 0) {
RETURN ""
}
VAR MINDISTANCE = INFINITY
VAR NEARESTSCHOOL = ""
FOR(VAR SCHOOL IN SCHOOLINTERSECT) {
VAR DIST = DISTANCE(SCHOOL, $FEATURE)
IF(DIST < MINDISTANCE) {
MINDIST = DIST
NEARESTSCHOOL = SCHOOL.SCHOOL_NAM
}
}
RETURN NEARESTSCHOOL
... View more
08-20-2021
06:53 AM
|
2
|
7
|
2574
|
|
POST
|
Modify this and run it in the python window. Test on a copy! prev_value = None
with arcpy.da.UpdateCursor("TableName", ["KeyBioMechanicalFeatures"]) as cursor:
for row in cursor:
this_value = row[0]
cursor.updateRow([prev_value])
prev_value = this_value
... View more
08-20-2021
06:44 AM
|
2
|
0
|
1464
|
|
POST
|
Well... A few days later, I now need the same thing. Now I tested it in an Attribute Rule, turns out it doesn't work there. @HusseinNasser2, any tips?
... View more
08-20-2021
06:08 AM
|
0
|
3
|
2631
|
| 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
|