How do I change shape and color based on two different attributes? And how do I fix the color bar?

1032
14
Jump to solution
01-18-2024 10:51 AM
Labels (2)
GraceKowalski
New Contributor II

Hello! I have ArcGIS Pro version 3.2, I believe. I'm trying to plot temperature data as a color and then sensor type as a shape. Say, for example, I have 8 sensor types. There are two I care about and want to make a triangle, the rest are circles. I think I found a way to do that by using "Unique Value" in the Symbology pane, then just changing the ones I want to which shapes I want. Then I want color to vary by temperature.  I want to the "Vary symbology by attribute" pane to change color according to temperature. But then it makes the color look confusing, where it only labels the highest and lowest values, and the rest are just in the middle. I want to have the color bar range from 17-23 by 0.5 deg C intervals. Is there a way to do this? I tried in Arcade but got an error, so I may not know how to type in it. Also, just in general, is there any easier way to do this whole thing?

Screenshot for confusing color bar legend:

GraceKowalski_0-1705603709900.png

Screenshot of attempted Arcade code and error:

GraceKowalski_1-1705603794149.png

I would then go through and write code for it up until number 23, but I can't get past this first error. Thank you for any help!

0 Kudos
1 Solution

Accepted Solutions
ZachBodenner
MVP Regular Contributor

Sure, okay so I don't really know exactly what the different sensor types are, but another option would be to copy the layer by right clicking it in the table of contents, and pasting it there so you have two of the same layer. Then you can switch the definition query of your new layer to be the opposite (ie. show only AS and CT) and change those symbols to circles:

ZachBodenner_0-1705685269141.png

Then, to make your legend easier to manage in the layout, you can change the Label value in the symbology pane (mine will look different than yours because you have more values in your CSV but you see the idea):

ZachBodenner_1-1705685348415.png

ZachBodenner_2-1705685361504.png

Then you go ahead and add a legend to your layout and there will be two legend items, one for each layer (and therefore groups of sensors). 

View solution in original post

14 Replies
ZachBodenner
MVP Regular Contributor

You're on the right track with your arcade expression, just needs some syntax tweaking. Try:

 

var temp = $feature.Temp
When(temp >17 && temp <17.5,17,...,FINAL VALUE)

 

A When statement like this would enable you to group all of your bins together in one expression. replace the ... in the code above with as many pairs as necessary, so that you have a statement (eg. temp <17 && temp<17.5) and a return, which comes after the comma. When requires a default value at the end, so any values not captured by your expression will get that value. 

 

Full disclosure, I haven't played around with varying symbology by attribute, but hopefully that Arcade helps you on the right track.

0 Kudos
GraceKowalski
New Contributor II

Thank you for the help! I did get the Arcade code working, but it is unfortunately not improving the appearance of my legend. The whole middle group still does not get designated individual colors, and they just lump it all together. 

Here is the legend:

GraceKowalski_0-1705607862385.png

And here is the code:

GraceKowalski_1-1705607943447.png

 

0 Kudos
ZachBodenner
MVP Regular Contributor

I'm not sure if this will solve the legend issue, but it looks like you might have a slight problem of "dropping" values because you don't use an "greater than or equal to" type notation. Here's the list of Arcade operators:

https://developers.arcgis.com/arcade/guide/operators/

For example, in the second pair of you When statement, you'd want temp >= 17.5 instead of temp > 17.5

 

Also just to make your life easier, when you post code here, you can click the 3-dot-menu and then include your code using this button:

ZachBodenner_0-1705608275943.png

Then it's easier for everyone to copy-paste your code instead of typing out your screenshot!

 

Try changing around your operators and see what that does.

0 Kudos
GraceKowalski
New Contributor II

Thank you again! That was good to point out. I went through and added the equal to operators, but the legend sadly didn't change. I wonder if there's a more simple fix that I'm just missing. And thank you for pointing out how to include code! I'll do that here.

New code:

var temp = $feature.temp;
When(temp>17 && temp<=17.5, 17.0, temp>17.5 && temp<=18, 17.5, temp>18 && temp<=18.5, 18.0, temp>18.5 && temp<=19, 18.5, temp>19 && temp<=19.5, 19.0, temp>19.5 && temp<=20, 19.5, temp>20 && temp<=20.5, 20.0, temp>20.5 && temp<=21, 20.5, temp>21 && temp<=21.5, 21.0, temp>21.5 && temp<=22, 21.5, temp>22 && temp<=22.5, 22.0, temp>22.5 && temp<=23, 22.5, temp>23 && temp<=23.5, 23.0, temp>23.5 && temp<=24, 23.5, 24);

New legend (still looks the same where the middle is not separated):

GraceKowalski_0-1705614759823.png

 

0 Kudos
ZachBodenner
MVP Regular Contributor

Are you able to package your data as a shapefile? I'd be interested to bring this into my Pro and check it out.

0 Kudos
GraceKowalski
New Contributor II

I've been using it as a csv. If you want it in a shapefile, I'll have to learn how to do that first. I'm pretty new to ArcGIS, if you couldn't tell lol.

0 Kudos
ZachBodenner
MVP Regular Contributor

Ah okay so how are you doing the symbolizing in this case? Or rather, how are you getting your CSV into Pro in a way that you can symbolize points? And yeah feel free to send it as a CSV, I can try to replicate your process.

0 Kudos
GraceKowalski
New Contributor II
Sensor TypeLatitudeLongitudeTemp
AS39.3280276.6237817.2437
CT39.2913676.6364920.4375
GB39.3114376.600821.1562
AS39.3157576.6176518.5781
DQ39.3272576.6114820.6652
DQ39.3267876.6779419.7483

This is an example table because I don't know how to attach the csv file. But I saved it as a csv, then used the "Add Data" button to add it into my GIS project. Then I used the "XYtoPoint" tool and used the longitude as x and latitude as y to plot each point. Then I did what I stated in my initial post. I only care about sensors DQ and GB. So I went and used "Unique Value" in the Symbology pane, just changing the ones I want to triangles. Then I went to the "Vary symbology by attribute" pane to change color according to temperature. And I used the arcade code to try and fix the legend.

0 Kudos
ZachBodenner
MVP Regular Contributor

Ok got it, I'll let you know what I figure out! 

When you're writing a post or replying, there's a file uploader at the bottom.

ZachBodenner_0-1705671150570.png

 

0 Kudos