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
|
1638
|
POST
|
You're trying to use a list of layers as input, but the tool expects a layer. So you will have to create your output fc and iterate through your SampleLines and append the result to the oputput fc. Or you can do it with an InsertCursor. And at that point, you can take the next logical step and skip the tools altogether and just use the geometry methods. input_point_fcs = ["TestPoints"]
bearings = [0, 90, 180, 270, 45]
distances = [50, 100, 150, 200]
output_folder = "memory"
output_name = "result"
output_fc = arcpy.management.CreateFeatureclass(output_folder, output_name, "POINT")
arcpy.management.AddField(output_fc, "Source", "TEXT")
arcpy.management.AddField(output_fc, "Bearing", "DOUBLE")
arcpy.management.AddField(output_fc, "Distance", "DOUBLE")
with arcpy.da.InsertCursor(output_fc, ["SHAPE@", "Source", "Bearing", "Distance"]) as i_cursor:
for point_fc in input_point_fcs:
with arcpy.da.SearchCursor(point_fc, ["SHAPE@"]) as s_cursor:
for point, in s_cursor:
for bearing in bearings:
for distance in distances:
new_point = point.pointFromAngleAndDistance(bearing, distance)
i_cursor.insertRow([new_point, point_fc, bearing, distance])
... View more
01-13-2023
03:12 AM
|
0
|
1
|
680
|
POST
|
# instead of a DataFrame, define your data as a simple twodimensional list
rows = []
column_names = ["DomainName", "DomainType", "Index", "Code", "Description", "Min", "Max"]
# fill the list
for domain in domains:
if domain.domainType == "Range":
row = [domain.name, domain.domainType, 0, None, None, domain.range[0], domain.range[1]]
rows.append(row)
else:
for i, (k, v) in enumerate(domain.codedValues.items()):
row = [domain.name, domain.domainType, i, k, v, None, None]
rows.append(row)
# convert to DataFrame
dataframe = pd.DataFrame(rows, columns=column_names)
# export
dataframe.to_csv("N:/folder/domains.csv", index=False)
dataframe.to_excel("N:/folder/domains.xlsx", index=False)
... View more
01-13-2023
02:34 AM
|
2
|
0
|
813
|
POST
|
numMonths = arcpy.GetParameterAsText(3) You're inputting a string into relativeDelta. Try these: numMonths = arcpy.GetParameter(3)
numMonths = int(arcpy.GetParameterAsText(3))
... View more
01-12-2023
08:50 AM
|
1
|
1
|
647
|
IDEA
|
Oof... Some incoherent points off the top of my head: The field calculator is clunky enough in its present state. We have questions here regarding syntax pretty often, especially for users not using the GUI, but calling the calculator in scripts (having to supply the expression as string). If you introduce regex into there, you will probably get a lot of questions about that. Regex is... let's say "not the most intuitive". I'm by no means a power user, but I have used it in some instances. I still don't have a clue what I'm doing. Every regex expression I've ever used was heavily inspired by online searches and long sessions on regex101. If I look at some of those expressions now, I only know what they're supposed to find because I documented it. I feel like the complicated syntax would stop many users cold in their tracks, leading to frustration and to them just using string.replace() anyway. Who's your audience here? I think most users who both know of regex and consider using it know enough about Python to either import re in the calculator or skip the calculator altogether and go straight for the UpdateCursor. On the other side, there's a big chance that users who are not as experienced in Python (or programming in general) have never even heard of regex. Swamping those users in regex syntax doesn't seem like a good idea to me. So, personally, I think it would lead to much confusion for little benefit. Having said that, I don't know how QGIS does this. Maybe I'm making up problems and there are good ways of avoiding that confusion...
... View more
01-12-2023
08:43 AM
|
0
|
0
|
958
|
POST
|
The font tag has been deprecated. Instead, colors should be defined with css, either in a stylesheet (impossible for popups) or as inline style. When I tested right now, the MapViewer automatically converted font tags to span tags with the appropriate color, but only for color names and hexcodes, not for rgb values. But those still work when you use the correct syntax. <p>
Using color names: <span style="color:red;">Red</span>, <span style="color:green;">Green</span>, <span style="color:blue;">Blue</span>
</p>
<p>
Using hex codes: <span style="color:#ff0000;">Red</span>, <span style="color:#00ff00;">Green</span>, <span style="color:#0000ff;">Blue</span>
</p>
<p>
Using rgb: <span style="color:rgb(255,0,0);">Red</span>, <span style="color:rgb(0,255,0);">Green</span>, <span style="color:rgb(0,0,255);">Blue</span>
</p>
... View more
01-12-2023
06:37 AM
|
0
|
1
|
395
|
POST
|
You can activate the time feature on layers. You seem to have done that (accidentally) for at least one of your layers. To deactivate: Go into the layer properties, switch to the Time tab, switch the Layer Time property to "No time". Do this for each layer. I'm not sure why you would see the time line on new and old projects. Do you use saved layer files in multiple projects?
... View more
01-12-2023
06:22 AM
|
0
|
4
|
525
|
POST
|
You can change the parameter states and values in getParameterInfo() and updateParameters(). You can change parameter warnings and errors in updateMessages(). In your case, you would do something like this: class SomeTool:
label = "SomeTool"
def getParameterInfo(self):
# define the parameters
parameters = [
arcpy.Parameter(...),
arcpy.Parameter(...),
arcpy.Parameter(...),
]
# change default values, filters, and visibility
parameters[0].filter.list = [1, 2, 3]
parameters[1].enabled = False
parameters[2].value = "default"
return parameters
def updateParameters(self, parameters):
if parameters[0].value == 1:
parameters[1].enabled = True
else:
parameters[1].enabled = False
def updateMessages(self, parameters):
parameters[0].setWarningMessage("You have been warned") For more, here'S the official doc: https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/parameter.htm
... View more
01-11-2023
10:50 PM
|
0
|
1
|
381
|
POST
|
Judging from the fields, you are writing this expression in the palm survey table. But it should be written for the palm layer.
... View more
01-11-2023
02:16 AM
|
0
|
0
|
600
|
POST
|
Ah. As far as I know, there's no way to do that dynamically. Only way I can think of is to have statically defined periods. So your users wouldn't be able to filter for "every point between these two arbitrary dates", only for "every point that falls into this predefined period". To do this, you can use this data expression: // load your points
var p = Portal("https://xxx/portal/")
var id = "abc"
var sublayer = 1
var date_field = "Zeitstempel"
var layer = FeaturesetByPortalItem(p, id, sublayer, [date_field], true)
// define the output
var output_dict = {
geometryType: "",
fields: [
{name: "Period", type: "esriFieldTypeString"},
{name: "TotalArea", type: "esriFieldTypeDouble"},
],
features: []
}
// define the periods as dictionary {period_name: [start, end]}
// The Union() function below takes a lot of time, so don't use too many periods!
var periods = {
"2020": [Date(2020, 0, 1), Date(2020, 11, 31)],
"2021": [Date(2021, 0, 1), Date(2021, 11, 31)],
"2022": [Date(2022, 0, 1), Date(2022, 11, 31)],
"2023": [Date(2023, 0, 1), Date(2023, 11, 31)],
"2020 - Q1": [Date(2020, 0, 1), Date(2020, 2, 31)],
"2020 - Q2": [Date(2020, 3, 1), Date(2020, 5, 30)],
"2020 - Q3": [Date(2020, 6, 1), Date(2020, 8, 30)],
"2020 - Q4": [Date(2020, 9, 1), Date(2020, 11, 31)],
}
// loop over the periods
for(var p in periods) {
// filter your points
var start = periods[p][0]
var end = periods[p][1]
var sql = `${date_field} >= @start AND ${date_field} <= @end`
var filtered_layer = Filter(layer, sql)
// buffer each point
var buffers = []
for(var f in filtered_layer) {
Push(buffers, Buffer(f, 10, "meters"))
}
// union all buffers
var unioned_buffers = Union(buffers)
// write new feature
var new_f = {attributes:{
Period: p,
TotalArea: Area(unioned_buffers, "square-meters")
}}
Push(output_dict.features, new_f)
}
// return the featureset
return Featureset(Text(output_dict)) Set the indicator's value to Sum of TotalArea. Instead of the date selector, use a category selector. Use your period names as categories. As action, filter the indicator's Period field. Now your users can filter by the periods you defined and get the unioned areas.
... View more
01-11-2023
01:53 AM
|
1
|
0
|
340
|
POST
|
Quick practical application of Dan's answer: land = "Land" #layer name or fc path
# convert vertices to points
land_points = arcpy.management.FeatureVerticesToPoints(land, "memory/land_points", "ALL")
# create Thiessen polygons for the vertices
# I'm assuming you can use planar calculations! If you need geodesic, use something else.
thiessen = arcpy.analysis.CreateThiessenPolygons(land_points, "memory/thiessen", "ALL")
# dissolve the Thiessen polygons -> centerlines between islands
centerlines = arcpy.management.Dissolve(thiessen, "memory/centerlines", "ORIG_FID")
# create buffers
bufferlines = arcpy.analysis.Buffer(land, "memory/bufferlines", "3 miles")
# intersect buffers and centerlines
intersect = arcpy.analysis.Intersect([bufferlines, centerlines], "memory/intersect")
# dissolve for ORIG_FID (Land_OID -> Vertices) and ORIG_FID_1 (Land_OID -> Buffer)
baselines = arcpy.management.Dissolve(intersect, "memory/baselines", ["ORIG_FID", "ORIG_FID_1"])
# finally, delete every feature where the FIDs don't match
with arcpy.da.UpdateCursor(baselines, ["OID@"], "ORIG_FID <> ORIG_FID_1") as cursor:
for row in cursor:
cursor.deleteRow() Islands outlined in red, the resulting baselines in yellow:
... View more
01-10-2023
07:28 AM
|
1
|
0
|
436
|
POST
|
Ah, sorry, I assumed for ArcGIS Pro. If you're publishing from Pro, you can try the options above and see if they translate to AGOL/Portal. If you're doing all your work in AGOL or don't want to publish a new layer: You can still go with option 1 Option 4: Unique Symbols, using an Arcade expression if($feature.ConfirmationField != "Yes") {
return "hidden"
}
return $feature.RoadType Then symbolize by unique symbols, drag and drop the "hidden" legend item into the "Other" category, and uncheck that:
... View more
01-10-2023
06:10 AM
|
1
|
1
|
2006
|
POST
|
It can be done, but not in the advanced formatting. In there, you can only access the current datapoint, you can't load featuresets. Instead, you need to calculate the buffers in a data expression, use that expression as input for your indicator, and then filter the indicator's data source using user supplied values. So, doing this step by step: Add an indicator Create a new data expression for it // load your points
var p = Portal("https://xxx/portal/")
var id = "abc"
var sublayer = 1
var date_field = "Zeitstempel"
var layer = FeaturesetByPortalItem(p, id, sublayer, [date_field], true)
// define the output
var output_dict = {
geometryType: "",
fields: [
{name: "DateField", type: "esriFieldTypeDate"},
{name: "BufferArea", type: "esriFieldTypeDouble"}
],
features: []
}
// create the buffers
for(var f in layer) {
var new_f = {attributes: {
DateField: Number(f[date_field]),
BufferArea: Area(Buffer(f, 10, "meters"), "square-meters")
}}
Push(output_dict.features, new_f)
}
// return the featureset
return Featureset(Text(output_dict)) Change the indicator's parameters: show the sum of the BufferArea field add some text Add a top or side bar Add a date selector to the bar Change these two parameters: Add an action: Filter the indicator's date field Now the user-selected date range filters the indicator's data source:
... View more
01-10-2023
02:17 AM
|
1
|
0
|
359
|
POST
|
An Arcade expression might not be the best way here. Going from this: Option 1: Definition query Go into the layer options, switch to the Definition Query tab. Click on "New definition query" and use the UI to only select the features where the confirmation field ("TextField2" in my case) is not null. Alternatively, only select where the confirmation field is equal to "Yes". Apply. This will hide all features with null values in the confirmation field, allowing you to use a simple symbology with unique values: Option 2: Unique values with multiple fields In the symbology tab, select both the road type field and the confirmation field ("TextField1" and "TextField2" in my case): Select each symbol where the confirmation field is null (Ctrl + left click to select multiple), remove those from the symbology: Uncheck "Show all other values": This will hide all features with null values in the confirmation field. BUT, while option 1 doesn't include those features in the layer, option 2 does, it only does not draw them. You can still see them in the attribute table, and they are still getting labeled: Option 3: Arcade expression Sure, you can do this. Change to "Single Symbol", format the symbol. Allow symbol property connections and click on the button next to the color picker: Click on the expression button, copy/paste and edit the expression below, apply everything. // hide unconfirmed features by giving them a fully transparent color
if($feature.TextField2 != "Yes") {
return "rgba(0, 0, 0, 0)"
}
// define a mapping of road type to color
var mapping = {
"Highway": "red",
"Two-Lane-Road": "rgb(0, 255, 255)"
}
// return the color corresponding to the feature's road type
return mapping[$feature.TextField] As with option 2, this will include the unconfirmed features in the layer, but will not draw them:
... View more
01-10-2023
01:06 AM
|
2
|
0
|
2024
|
Title | Kudos | Posted |
---|---|---|
1 | 08-30-2022 08:26 AM | |
1 | 08-24-2023 12:11 AM | |
1 | 02-06-2023 12:05 AM | |
1 | 12-05-2023 10:09 AM | |
1 | 02-07-2023 01:11 AM |
Online Status |
Offline
|
Date Last Visited |
02-03-2024
06:14 PM
|