POST
|
I haven't spent a lot of time working with python toolboxes in my career (no real need for them), but recently I've had to adapt what was meant to be a standalone script into a toolbox, after discovering a bug that affects CIM (v2) FeatureLayer objects that are accessed outside of an ArcGIS Pro application. My tool is designed to be run on an .aprx that contains small scale transportation maps (and associated layouts) with inset areas marked on them, alongside separate large scale maps (and associated layouts) covering the inset areas. The idea is to take each polyline layer in the small scale map and break it into two layers. Layer one retains the existing symbology, but is masked inside the bounds of the inset areas. Layer two is a copy of layer one with a definition query applied (limiting it to features that intersect the inset area), no layer mask, and reduced line weights for less visual clutter. My workflow in the standalone script went something like this: #1 Make the new layer, add it to the map, and move it to the correct location result = arcpy.management.MakeFeatureLayer(old_layer, new_name) pro_map.addLayer(result.getOutput(0)) new_inset_layer = pro_map.listLayers(new_name)[0] pro_map.moveLayer(old_layer, new_inset_layer, "AFTER") #2 Apply the Unique Values renderer to the new layer arcpy.management.ApplySymbologyFromLayer(new_inset_layer, old_layer) At this point, we need to bring in the CIM. ApplySymbologyFromLayer sets the new layer's renderer without issue, but it defaults to using the literal values from the attribute fields as labels for the symbol classes. That's no good; this is a Unique Value renderer with multiple fields and grouped values. We don't want a label that reads: Unpaved Road, SR; Unpaved Road, 4; Unpaved Road, 5; Unpaved Road, NA we just want it to say Unpaved Road. But we can pull those settings over from the old layer, too, using the CIM: #2A Copy labels inset_cim = new_inset_layer.getDefinition('V2') inset_cim.renderer.groups[0].classes = old_layer.getDefinition('V2').renderer.groups[0].classes From there, it's a relatively straightforward process of looking up the different symbol classes in a symbol dictionary that specifies the updated line weights and colors. (I could see how setting up a .lyrx template and retrieving the desired symbology from there might be easier than using a dictionary, but I was having fun learning the ins and outs of the CIM) So I've got a solution, but now I'm wondering: how does the derived output parameter(s?) even begin to fit into this picture? As already noted, there isn't a ton of documentation out there (maybe even less than there is for the CIM!) and this thread is one of the few links that come up when I search for help. (P.S. I would agree that this issue has not really been 'solved' in a meaningful way. I have no problem with Esri saying "We don't consider this a bug and we don't plan to fix it," but then they should at least provide with some clear, detailed examples of how the derived parameters workaround is intended to work.)
... View more
12-05-2023
08:47 AM
|
0
|
0
|
198
|
IDEA
|
Chelsea, Do you have any experience using the ArcGIS Assistant to edit the JSON of a web map or web feature layer? I recommend it to people all the time, as the level of control it gives you is really unparalleled; and while I haven't ever used it to solve this particular problem, I'd be very surprised if it can't do the exact thing you're asking about. Below is some sample JSON I had on hand. It's from a webmap I was working on recently. This is the section that specifies the graduated color symbology for a layer of census tracts, based on a tract's Score_State attribute: "layerType": "ArcGISFeatureLayer",
"layerDefinition": {
...
"visualVariables": [
{
"maxSliderValue": 21,
"minSliderValue": 0,
"theme": "above-and-below",
"type": "colorInfo"
}
]
},
"type": "classBreaks",
"visualVariables": [
{
"type": "colorInfo",
"field": "Score_State",
"stops": [
{
"color": [
117,
113,
114,
255
],
"value": 6
},
{
"color": [
188,
184,
180,
255
],
"value": 10
},
{
"color": [
218,
230,
213,
255
],
"value": 13
},
{
"color": [
158,
187,
81,
255
],
"value": 17
},
{
"color": [
93,
122,
6,
255
],
"value": 20
}
]
} Using the Assistant, I think you should be able to set up your symbology the way you want it by either of two routes. You could either use a text editor to type the exact values you want into the "stops" array (lines 20 - 66 above); or you could work in the Map Viewer to create the symbology you want in another feature layer (one with a greater number of features) and then copy and paste the JSON from that layer into your 4-precinct layer. I hope this workaround helps!
... View more
08-09-2023
02:43 PM
|
0
|
0
|
167
|
POST
|
I'm not sure how the index numbers for the layouts get assigned -- they seem kind of arbitrary to me. Possibly it depends on the order that in which the layouts were created? The layouts do have a name attribute, which you could use to construct a dictionary: layouts = p.listLayouts() l_dict = {l.name: l for l in layouts if not l.mapSeries is None} Alternately, if you know the name, you can use it as a wildcard when you call p.listLayouts(): l = p.listLayouts("yournamehere")[0] Note that the [0] is required even when searching for an exact name with only a single match among your layouts, because listLayouts() returns that match inside a list object.
... View more
07-21-2023
11:26 AM
|
0
|
1
|
321
|
POST
|
Having the exact same issue. I've tried every tool in my toolkit, from editing the JSON with ArcGIS Assistant to rebuilding the entire dashboard from scratch, but the problem persists. Selecting features on the map filters the values displayed in the serial chart, and selecting features in the category selector filters both the features displayed on the map and the values displayed in the serial chart, but I lose the ability to select features on the map whenever the category selector is active.
... View more
03-07-2023
08:19 AM
|
0
|
0
|
165
|
POST
|
UPDATE: Problem resolved! I needed to clean the original dataset better: the crash locations were generated via linear referencing, and there were a number of non-located points that had not been removed and were presumably interfering with the algorithm that determines the optimal symbol size based on density/extent. I'll leave this here in case anyone else in future has the same issue...
... View more
05-17-2021
12:55 PM
|
1
|
0
|
986
|
POST
|
I am having a strange issue with the auto scale adjustment in the new Map Viewer. I have two layers showing locations of auto crashes involving pedestrians in the state of North Carolina.* One is a TEST layer that I clipped to the boundary of a few of the state's more populous MPO jurisdictions; it has 5,703 records, and resizes beautifully as I zoom from block level out to regional/statewide level. (see screenshot1) After doing all of my testing with this clipped subset of the data, I brought in the STATEWIDE layer, which covers the entire state, consisting of 27,300 records. (see screenshot2) Unfortunately, when I try to use the "Adjust size automatically" setting on this new layer, I get very different results. No matter whether I zoom way out and manually set the size to be very small, or zoom in and make it larger, the automatic adjustments as I move between zoom levels are very slight when they happen at all. (See screenshot3) I understand that, as this Esri blog post notes, "The default sizes for each scale depend on the size and density of features in your layer. So you will not see the same sizes at similar scales for different layers." Even though one layer is just a clipped version of the other, the STATEWIDE layer has a much greater extent, so I don't expect them to behave exactly the same. But it seems odd that the TEST layer resizes smoothly every time I change scale, and the STATEWIDE layer does not resize at all until I am zoomed out almost far enough to show the layer's full extent! I don't think this is the intended behavior of this feature, and I'm curious whether anyone has encountered similar bugs. EDIT: Forgot to include the link to the Esri blog post referenced in the last paragraph: https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/auto-size-by-scale-now-available-in-map-viewer-beta/ *: These location data are collected by the U.S. Federal Government and made publicly available, so no privacy concerns re: posting these images 🙂
... View more
05-17-2021
08:06 AM
|
0
|
1
|
1044
|
POST
|
Hello, I'm a fairly new user of ArcGIS Pro (2.3.0), still trying to get my head around some of the changes to how projects are organized internally in Pro vs. ArcMap... so bear with me if I get some of the terminology wrong For a project I'm currently working on, I thought I might be able to take advantage of Pro's capability to store multiple layouts in a single project. (The outputs for this project are a series of county-level maps, but with enough variation between them in terms of scale, need to show surrounding areas beyond the county boundary, insets, etc, that the Map Series feature is not really a suitable choice.) After setting up one layout the way I wanted (title bar, legend, etc), I went to the Catalog view, opened the Project/Layouts folder, copied and pasted that layout to use as a starting point for the other layouts. But when I open the copy to start editing it, it's as if I'm looking at a static photocopy of the original layout: the contents pane is empty except for the "Layout" element, which has nothing under it when I expand it. I can click to select individual elements (map frame, legend, text box) in the view pane, but the context-sensitive menu on the top ribbon does not update to reflect my current selection. My last idea was to right-click an element in the view pane and examine its Properties menu to see if there was anything 'off' about it; but that just crashed the program, naturally. Is this a known bug which will be fixed in a future release? Creating a blank layout and copy-pasting all of the elements from the old layout will serve as a workaround, for the time being; but is there some better way I could be going about this? Thanks, Andrew
... View more
03-08-2019
06:18 AM
|
0
|
2
|
1126
|
Title | Kudos | Posted |
---|---|---|
1 | 05-17-2021 12:55 PM |
Online Status |
Offline
|
Date Last Visited |
02-09-2024
02:24 PM
|