|
POST
|
// change: load your school district field
var CURRENTSCHOOLS = FeatureSetByName($datastore, "ELEMENTARY_SCHOOL", ["School_Nam", "School_District"]);
// change: filter schools by district
var district = $feature.School_District
if(district != null) {
CURRENTSCHOOLS = Filter(CURRENTSCHOOLS, "School_District = @district")
}
// rest stays the same
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) {
MINDISTANCE = DIST
NEARESTSCHOOL = SCHOOL.SCHOOL_NAM
}
}
RETURN NEARESTSCHOOL
... View more
09-12-2021
11:04 PM
|
0
|
2
|
2396
|
|
POST
|
Hmm, couldn't get it to work, either. Possible workarounds: use the query in the MakeQueryLayer tool and search its output do it in python: selectClause = row[0] + " IS NOT NULL or CAST(" + row[0] + " AS CHARACTER(255)) <> ''"
fieldList2 = ["EvaluationID", "ObjectID"]
tableData = [row for row in arcpy.da.SearchCursor(table, fieldList2, selectClause)]
uniqueEvaluationIDs = {td[0] for td in tableData}
for evaluationID in uniqueEvaluationIDs:
count = len([td for td in tableData if td[0] == evaluationID])
print "count of {}: {}".format(evaluationID, count)
... View more
09-08-2021
10:40 PM
|
0
|
1
|
1974
|
|
POST
|
I have no idea why this happens, but to not let it fail your script, you can do it in a try-catch block: for lyr in updateMap.listLayers():
try:
arcpy.AddMessage(lyr.dataSource)
except NameError:
pass
... View more
09-07-2021
10:30 PM
|
1
|
0
|
2777
|
|
POST
|
Is it possible to automate an arcade expression like you would a python script? Depends. You can't execute an Arcade expression in certain intervals like you could with a Python script. But you can write Attribute Rules that automatically calculate your field. If not, is there an easy way to run it, wrapped in a python script, from within the Model Builder? You can use your Arcade expression in the Calculate Field tool. Arcade is being used to make the end result pretty If all you want to do with Arcade is to prettify things, you could also do that in the Popup.
... View more
09-03-2021
01:18 AM
|
0
|
1
|
2652
|
|
POST
|
Ah, my bad. I thought fromTerminal and associationType were attributes, but they seem to be keywords of the utility network.
... View more
09-03-2021
12:58 AM
|
0
|
0
|
2939
|
|
POST
|
Delete all Mean_Amount and Mean_Age fields Create Mean_Amount and Mean_Age in your summary table After "Join Field (2)", calculate the original fields to be equal to the newly joined fields, then delete the joined fields.
... View more
09-02-2021
03:23 AM
|
0
|
0
|
2822
|
|
POST
|
If the database is an Enterprise Geodatabase, you can use this SQL query to create a query layer (saved in the map document) or database view (saved in the database): SELECT d.OBJECTID, d.Shape, d.AreaCode, a.AverageAge, i.AverageIncome
FROM Districts d
LEFT JOIN (
SELECT AreaCode, AVG(Age) AS "AverageAge"
FROM AgeData
GROUP BY AreaCode
) AS "a"
ON a.AreaCode = d.AreaCode
LEFT JOIN (
SELECT AreaCode, AVG(Income) AS "AverageIncome"
FROM IncomeData
GROUP BY AreaCode
) AS "i"
ON i.AreaCode = d.AreaCode https://pro.arcgis.com/de/pro-app/latest/tool-reference/data-management/make-query-layer.htm https://pro.arcgis.com/de/pro-app/latest/tool-reference/data-management/create-database-view.htm
... View more
09-02-2021
02:03 AM
|
0
|
2
|
2836
|
|
POST
|
Do you get an error when inserting a feature or does it work but doesn't create the connection? One thing I noticed: Your association_updates are wrong. An update is defined as {"globalID": "GUID-of-the-updated-feature", "attributes": {"Field1": "Value1", "Field2": "Value2"}} So your line 69 (use accordingly for lines 71, 162, 176) should be //var assocation_update = [{'globalID': closestf.globalID, 'fromTerminal': 'SS:S2' ,'associationType': 'connected'}];
var assocation_update = [{'globalID': closestf.globalID, 'attributes': {'fromTerminal': 'SS:S2' ,'associationType': 'connected'}}];
... View more
09-01-2021
10:07 PM
|
0
|
2
|
2972
|
|
POST
|
You can't iterate FeatureLayers. Create a SearchCursor and iterate that: fields = [f.name for f in arcpy.ListFields(PLS)] # or define a subset of fields
print(fields)
with arcpy.da.SearchCursor(PLS, fields) as cursor:
for row in cursor:
print(row)
... View more
09-01-2021
02:26 AM
|
2
|
1
|
3539
|
|
POST
|
Hmmm, interesting. 4 vertices and distance(v1, v3) ~ distance(v2, v4): rectangle, else irregular quadrangle. (Almost) circles: for each vertex, get the distance from the centroid. get min and max distance. if max - min ~ 0: it's a circle, else it's something else. or: calculate the isoperimetric quotient of the polygon (https://en.wikipedia.org/wiki/Isoperimetric_inequality, https://en.wikipedia.org/wiki/Polsby%E2%80%93Popper_test😞 Q = 4*pi*area/(perimeter^2) For Q == 1 it's a circle; the lower Q gets, the less circle-ish the shape is. rectangle-ish shapes with more than 4 vertices: get bearing of each line segment. if bearing[i] ~ bearing[i+1], it's the same side. if you get 4 sides this way, you know its a quadrangle. get the angles between the sides. if they're ~90°, it's a rectangle.
... View more
09-01-2021
02:05 AM
|
3
|
2
|
6974
|
|
POST
|
Your example doesn't state what the dictionary keys would be. As it looks right now, you could just do this: // Calculation Rule on Field 2
// Triggers: Update, Insert
// return early if Field1 is empty
if(IsEmpty($featue.Field1)) {
return $feature.Field2 // or return null
}
// create the dictionary
var value_dict = {
"R-1": "Single-Family District",
"ABC": "Other stuff",
}
// return the right value for Field2
return value_dict[$feature.Field1]
// you could also do it with a list:
value_list = [
["R-1", "Single-Family District"],
["ABC", "Other stuff"],
]
for(var i in value_list) {
if(value_list[i][0] == $feature.Field1) {
return value_list[i][1]
}
}
// return a default value if Field1 is not in the list
return null
... View more
08-31-2021
11:11 PM
|
1
|
1
|
3452
|
|
POST
|
# here you specify D:\outputData as workspace (a folder)
arcpy.env.workspace = "D:\\outputData"
# this only works with Enterprise geodatabase connections. if you don't have any of those, you don't need this
arcpy.ClearWorkspaceCache_management()
# does the raster have a file extension?
inputData = "D:\\quad_dem10"
# here you specify D:\outputData as a raster. but it is a folder...
outputData ="D:\\outputData"
# things to check:
# is D:\outputData a folder?
# if yes, change your Clip output to D:\outputData\outputRasterName
# if no, delete the arcpy.env line (you can probably do that anyway)
# open the tool (Data Management Tools -> Raster -> Raster Processing -> Clip), put in the parameters from your script and try running it manually
... View more
08-30-2021
11:07 PM
|
0
|
1
|
4918
|
|
POST
|
You have several problems in your code: "subjectitems" is a dataset with the filtered results of tbl_subjectitems. the individual subjectitems are named "si" (see line 23 in your code). you define tableresults inside the loop (line 25). for each found subjectitem, you overwrite the results of the previous ones. you append tableresults to itself (line 26), that's why you get two identical lines. tableresults is created for each mantenimiento, but you only append it to historia (results of all mentnemientos) at the very end (line 37), so you will only see the tableresults of the last processed mantenimiento. Try this: // Write a script to return a value to show in the pop-up.
// For example, get the average of 4 fields:
// Average($feature.SalesQ1, $feature.SalesQ2, $feature.SalesQ3, $feature.SalesQ4)
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):" + TextFormatting.NewLine;
for (var mantenimiento in mantenimientos) {
// from your original post
var txt_ActivityNum = Text("Activity Number: " + mantenimiento.ACTIVITY_NUM);
var txt_fecha = txt_ActivityNum + "- Doc Status Date: " + Text(mantenimiento.DOC_STATUS_DATE, '(Y/MM/DD) - ');
var txt_docdes = txt_fecha + "Status: " + mantenimiento.DOC_STATUS_DESC;
historia += TextFormatting.NewLine + txt_docdes;
// filter tbl_subjectitems
var doc_id = mantenimiento.INT_DOC_ID
var subjectitems = Filter(tbl_subjectitem, "INT_DOC_ID = @doc_id")
// define tableresults outside of the loop avoid overwriting it for each subjectitem
var tableresults = ""
for(var si in subjectitems) {
// subjectitems is the filtered dataset. the individual features are called "si".
var txt_SubjectItemDesc = "Subject Item: " + si.subject_item_description;
// append to tableresults
tableresults += TextFormatting.NewLine + txt_SubjectItemDesc;
}
// do the same for tbl_contacts
var contacts = Filter(tbl_contact, "INT_DOC_ID = @doc_id")
for(var c in contacts) {
// ...
}
// append tableresults (output of the filtered subjectitems & contacts for one mantenemiento) to historia (output of all mantenemientos)
historia += TextFormatting.NewLine + tableresults
}
}
else {
historia = "No Records";
}
return historia;
... View more
08-30-2021
06:35 AM
|
0
|
2
|
4276
|
|
POST
|
It's possible to georeference CAD data in ArcMap and ArcGIS Pro. ArcMap: https://desktop.arcgis.com/de/arcmap/latest/manage-data/cad/georeferencing-cad-datasets.htm ArcGIS Pro: https://pro.arcgis.com/de/pro-app/latest/help/data/cad/georeferencing-cad-data.htm It should also be possible to do it in Autocad, but I don't know how.
... View more
08-30-2021
06:02 AM
|
0
|
0
|
3154
|
|
POST
|
You just have to order your code differently: var Status = $feature.RefStatus
// exit early if RefStatus is null
if(IsEmpty(Status)) {
return ''
}
var cover_status = [
'Ants present under artificial cover object',
'Artificial cover object not found',
'Artificial cover object not checked'
]
var water_status = [
'Current',
'Empty',
'Inaccessible',
'Polluted'
'Filled'
]
if(Includes(cover_status, Status)) {
return 'Artificial cover object status: ' + Status
}
if(Includes(water_status, Status)) {
return 'Waterbody status: ' + Status
}
return ''
// for older Arcade versions (< Arcade 1.12):
var status_type = ''
if (Status=='Ants present under artificial cover object' || Status=='Artificial cover object not found' || Status=='Artificial cover object not checked') {
return 'Artificial cover object status: ' + Status
}
if (Status=='Current' || Status=='Empty' || Status=='Inaccessible' || Status=='Polluted' || Status=='Filled') {
return 'Waterbody status: ' + Status
}
return ''
... View more
08-30-2021
01:07 AM
|
1
|
1
|
5130
|
| 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
|