|
POST
|
var values = [
$feature.f0,
$feature.f0spare,
$feature.dead,
$feature.f1
]
for(var v in values) {
var value = values[v]
if(Count(value) > Count(Replace(value, "SPL", ""))) {
value = Replace(value, ":", "")
value = Replace(value, ",", "")
return Split(value, " ")[1]
// you return the first found column, the next columns won't be evaluated.
}
}
// return a default value if no column contains a value with "SPL"
return null
... View more
09-19-2021
11:34 PM
|
1
|
1
|
3575
|
|
POST
|
var id = $feature.ParcelID;
var relatedtable = FeatureSetById($datastore, "1");
var filtereddata = Filter(relatedtable, "ParcelID = @id");
var permits = []
var url_pre = "https://asbuilts.ci.missoula.mt.us/scards/"
var url_post = ".pdf"
for (var permit in filtereddata) {
permits[Count(permits)] = url_pre + permit["PermitNumber"] + url_post
// in ArcGIS Pro 2.8 or later you can do
// Push(permits, url_pre + permit["PermitNumber"] + url_post)
}
// if you show the popup's normal attribute table, one of these should work
return Concatenate(permits, TextFormatting.NewLine)
return Concatenate(permits, "\n")
// if you show custom HTML code, this should work
return Concatenate(permits, "<br/>") Note that there is currently no easy way for the popup to actually format those urls as links. Your users will have to copy/paste them.
... View more
09-19-2021
11:19 PM
|
0
|
0
|
2613
|
|
POST
|
If the rule returns an empty string, it means it didn't find a school in teh specified search radius. If it worked before adding the filter, then the problem is probably in the filter. make sure that ELEMENTARY_SCHOOL.DISTRICT_1 and PROPERTIES.School_District are of the same data type make sure that School_District is a value that can actually be found in DISTRICT_1 include better log messages (at least temporarily) var log = ""
var CURRENTSCHOOLS = FeatureSetByName($datastore, "ELEMENTARY_SCHOOL", ["School_Nam", "DISTRICT_1"]);
log += Count(CURRENTSCHOOLS) + " schools loaded; "
var district = $feature.School_District
if(!IsEmpty(district)) {
log += "filtering schools by '" + district + "'; "
CURRENTSCHOOLS = Filter(CURRENTSCHOOLS, "DISTRICT_1 = @district")
log += Count(CURRENTSCHOOLS) + " schools found; "
} else {
log += "School_District is empty; "
}
VAR SEARCHDISTANCE = 30;
VAR SCHOOLINTERSECT = INTERSECTS(CURRENTSCHOOLS, BUFFER($FEATURE, SEARCHDISTANCE, "MILES"))
log += Count(SCHOOLINTERSECT) + " schools found in the search radius; "
IF(SCHOOLINTERSECT == null || COUNT(SCHOOLINTERSECT) == 0) {
return log
}
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-15-2021
01:38 AM
|
0
|
0
|
2364
|
|
POST
|
Sorry, I always forget that the sql query depends on the DBMS... The one I used is for SQL Server. If you're working with a file geodatabase, try this: import arcpy
import datetime
table = "DBF_ExRainfall"
date_field = "Dates"
# extract the dates from the table and format them:
# list of datetime.datetime objects
# [datetime.datetime(2018, 9, 25, 8, 36, 54), datetime.datetime(2018, 9, 25, 8, 58, 24)]
dates = [row[0] for row in arcpy.da.SearchCursor(table, [date_field], "{} IS NOT NULL".format(date_field))]
# convert to str
# ['2018-09-25', '2018-09-25']
date_strings = [d.strftime("%Y-%m-%d") for d in dates]
# make it distinct
# ['2018-09-25']
distinct_date_strings = list(set(date_strings ))
# create feature layers for each date
for d in distinct_date_strings:
start_date = datetime.datetime(*[int(x) for x in d.split("-")])
end_date = start_date + datetime.timedelta(days=1)
where_clause = "{0} >= date '{1}' AND {0} < date '{2}'".format(
date_field,
start_date.strftime("%Y-%m-%d"),
end_date.strftime("%Y-%m-%d"))
lyr = arcpy.management.MakeFeatureLayer(table, d, where_clause)
# if you want it as feature class (saved in database):
#out_fc = os.path.join(gdb_path, d)
#arcpy.management.CopyFeatures(lyr, out_fc) If you're working on another DBMS, I can't help you with the query, but here is the SQL reference for ArcGIS which includes syntax for filtering by date: https://pro.arcgis.com/de/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm
... View more
09-15-2021
12:25 AM
|
1
|
0
|
5604
|
|
POST
|
I'm pretty late to the party, but maybe it still helps... You have to return a string. return "rgb(255, 255, 0)"
return "rgba(255, 255, 0, 0.5)"
return "red" The documentation is here: https://pro.arcgis.com/de/pro-app/latest/help/mapping/layer-properties/attribute-driven-color-in-symbology.htm
... View more
09-14-2021
07:04 AM
|
1
|
1
|
3994
|
|
POST
|
Also, I'm on 2.6.3, Enterprise GDB, so no big differences there.
... View more
09-14-2021
06:43 AM
|
1
|
0
|
2174
|
|
POST
|
Line 1: Try changing the boolean parameter (includeGeometry) to true. https://developers.arcgis.com/arcade/function-reference/data_functions/#featuresetbyname
... View more
09-14-2021
06:38 AM
|
0
|
1
|
2174
|
|
POST
|
var settlement_bands = ["B", "G", "H"]
if(Includes(settlement_bands, $feature.Band)) {
return "Settlement"
}
return "Non settlement" You can use that expression in the CalculateField tool (switch language to Arcade) to permanently store it in the table in the popup, to show it only there (useful if it changes a lot) in an Attribute Rule, to store it permanently in the table whenever a featire is created and/or updated
... View more
09-14-2021
03:07 AM
|
1
|
0
|
2540
|
|
POST
|
"in_memory" is the legacy workspace from ArcMap. ArcGIS Pro uses "memory", try using that.
... View more
09-14-2021
03:00 AM
|
1
|
1
|
3728
|
|
POST
|
Sorry if you already know this, but your post doesn't seem like it: There is a difference between a "feature class" and a "feature layer". The class ist the physical object stored in the database. The layer is (very roughly speaking) a representation of that class, which allows you to do certain things that you can't do directly with the class (e.g. selection, symbology). So when you make a feature layer of Brighton_Zoning, this is NOT a copy. If you succeed deleting a field from the layer, it will be deleted from the underlying feature class, too! As to your problem: I find fiddling with the field mapping for the Append tool too cumbersome, so I'd do it with the Cursors: https://pro.arcgis.com/de/pro-app/latest/arcpy/get-started/data-access-using-cursors.htm # create the output feature class
# creating it in memory makes everthing faster, you just have to copy it to a gdb afterwards
out_fc = arcpy.management.CreateFeatureclass("memory", "out_fc", "POLYGON")
# add the output fields
arcpy.management.AddField(out_fc, "TextField", "TEXT")
arcpy.management.AddField(out_fc, "IntegerField", "LONG")
# create a list of feature classes to append, their fields, and sql queries determining the entries that are to be copied
# fields have to be in the same order for each fc
# geometry type has to be the same for each fc
append_fcs = [
{"path": "path/of/fc1", "fields": ["SHAPE@", "TEXT", "INTEGER"], "sql": None},
{"path": "path/of/fc2", "fields": ["SHAPE@", "Text_Field", "Integer_Field"], "sql": "Text_Field LIKE '%abc%'"},
]
# start the insert cursor
with arcpy.da.InsertCursor(out_fc, ["SHAPE@", "TextField", "IntegerField"]) as i_cursor:
# loop though append_fcs and copy each row to out_fc
for fc in append_fcs:
with arcpy.da.SearchCursor(fc["path"], fc["fields"], fc["sql"]) as s_cursor:
for row in s_cursor:
i_cursor.insertRow(row)
... View more
09-14-2021
02:55 AM
|
1
|
1
|
3549
|
|
POST
|
When you say "clip", do you mean "copy"? If so, the relationship classes and related tables /feature classes should get copied automatically.
... View more
09-14-2021
02:07 AM
|
0
|
0
|
911
|
|
POST
|
import arcpy
table = "DBF_ExRainfall"
date_field = "Dates"
# extract the dates from the table and format them:
# list of datetime.datetime objects
# [datetime.datetime(2018, 9, 25, 8, 36, 54), datetime.datetime(2018, 9, 25, 8, 58, 24)]
dates = [row[0] for row in arcpy.da.SearchCursor(table, [date_field], "{} IS NOT NULL".format(date_field))]
# convert to str
# ['2018-09-25', '2018-09-25']
date_strings = [d.strftime("%Y-%m-%d") for d in dates]
# make it distinct
# ['2018-09-25']
distinct_date_strings = list(set(date_strings ))
# create feature layers for each date
for d in distinct_date_strings:
where_clause = "DATEDIFF(DAY, {}, '{}') = 0".format(date_field, d)
lyr = arcpy.management.MakeFeatureLayer(table, d, where_clause)
# if you want it as feature class (saved in database):
#out_fc = os.path.join(gdb_path, d)
#arcpy.management.CopyFeatures(lyr, out_fc)
... View more
09-14-2021
01:59 AM
|
1
|
2
|
5626
|
|
POST
|
Building on what David suggested: IIf(Replace($feature.FaxPhone, ' ', '') == '()-', '', $feature.FaxPhone) Also, make sure you're actually showing the expression in the popup, not the field.
... View more
09-14-2021
01:25 AM
|
0
|
0
|
1193
|
|
POST
|
var PolyFC =Intersects(FeatureSetByName($datastore, "gewaesserkataster_sde.GWK_SDE_ADMIN.poly"), $feature)
// return early if no intersecting polygon is found
// doing it this way saves you from indenting everything in your if block
if(PolyFC == null || Count(PolyFC) == 0) {
return null
}
// lines have the "paths" attribute, for polygons that's "rings"
var poly = First(PolyFC)
var geom = Geometry(poly)
var pt0 = geom.rings[0][0]
var brg = Bearing(pt0, Geometry($feature))
if (brg > 90 && brg <= 360) {
return (450 - brg)
}
return (90 - brg)
// if that works for you, cool.
// I got really inconsistent results when testing this on irregular polygons, though,
// so I'd go with something like this:
var poly = First(PolyFC)
var vertices = Geometry(poly).rings[0]
var sr = Geometry(poly).spatialReference
// loop through the vertices
for(var r=0; r<Count(vertices)-1; r++) {
// create a line segment between 2 adjacent vertices
var p0 = vertices[r]
var p1 = vertices[r+1]
var line = Polyline({"paths": [[ [p0.x, p0.y], [p1.x, p1.y] ]], "spatialReference": sr})
// do nothing if $feature doesn't intersect that line segment
if(Disjoint($feature, line)) {
continue
}
// return the bearing of the line segment
var brg = Bearing(p0, p1)
if (brg > 90 && brg <= 360) {
return (450 - brg)
}
return (90 - brg)
}
// if you land here, the feature intersects a polygon, but none of its edges
return null
... View more
09-13-2021
11:41 PM
|
1
|
4
|
2180
|
|
POST
|
I think (not sure), ArcGIS uses the compiled pyc file unless you explicitly reload the module in your toolbox. # toolbox.pyt
import importlib
import your_module
importlib.reload(your_module)
from your_module import *
# To see changes made in modules you import in your_module,
# you have to reload them in your_module, too:
# your_module.py
import importlib
import utility_functions
importlib.reload(utility_functions)
from utility_functions import *
... View more
09-12-2021
11:22 PM
|
2
|
1
|
4028
|
| 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
|