<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1">
Thank you for this. I think my software may be too old and has caused the problem. I am running R version 4.2.2 Patched (2023-01-29 r83721) and sf_1.0-9 . I will get it updated.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);" class="elementToProof ContentPasted0 ContentPasted1">
Scott<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Zivan Karaman <zivan.karaman@gmail.com><br>
<b>Sent:</b> Friday, September 27, 2024 12:47 PM<br>
<b>To:</b> Waichler, Scott R <Scott.Waichler@pnnl.gov><br>
<b>Cc:</b> r-sig-geo@r-project.org <r-sig-geo@r-project.org>; edzer.pebesma@uni-muenster.de <edzer.pebesma@uni-muenster.de><br>
<b>Subject:</b> Re: [R-sig-Geo] unexpected attribute plotting with sf polygons</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="x_gmail_default" style="font-family:arial,sans-serif; font-size:small">
When I run your code I get Time1 in one color and Time2 in another color, as expected.</div>
<div class="x_gmail_default" style="font-family:arial,sans-serif; font-size:small">
<img alt="image.png" width="562" height="328" data-outlook-trace="F:1|T:1" src="cid:ii_m1l4wo8g0"><br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Fri, Sep 27, 2024 at 8:23 PM Waichler, Scott R <<a href="mailto:Scott.Waichler@pnnl.gov">Scott.Waichler@pnnl.gov</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div class="x_msg-8886561929422908319">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
Thanks for the comments, but it's still not working. The version below uses vectors instead of a matrix for the attributes, but it's still making two plots all of the same color. Time1 should be one color, Time2 should be the other. As should be clear from
my attribute names, I am trying to use the lattice-like paneling capability to represent values at different times of the same variable.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
my.text <-
<div>c("POLYGON ((0 2.69, 4.483057 2.86, 4.483057 2.76, 0 2.59, 0 2.69))", </div>
<div> "POLYGON ((0 2.59, 4.483057 2.76, 4.483057 2.26, 0 2.09, 0 2.59))", </div>
<div> "POLYGON ((0 2.09, 4.483057 2.26, 4.483057 1.26, 0 1.09, 0 2.09))", </div>
<div> "POLYGON ((0 1.09, 4.483057 1.26, 4.483057 -0.74, 0 -0.91, 0 1.09))")</div>
<div>my.poly <- st_as_sfc(my.text)</div>
<div>my.poly2 <- st_sf(Time1 = rep(1,4), Time2 = rep(2,4), geom = my.poly)</div>
<div>plot(my.poly2, breaks = c(0.5, 1.5, 2.5))</div>
<div><br>
</div>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255)">
--Scott Waichler<br>
</div>
<div id="x_m_-8886561929422908319appendonsend"></div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-8886561929422908319divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Zivan Karaman <<a href="mailto:zivan.karaman@gmail.com" target="_blank">zivan.karaman@gmail.com</a>><br>
<b>Sent:</b> Friday, September 27, 2024 9:37 AM<br>
<b>To:</b> Waichler, Scott R <<a href="mailto:Scott.Waichler@pnnl.gov" target="_blank">Scott.Waichler@pnnl.gov</a>><br>
<b>Cc:</b> <a href="mailto:r-sig-geo@r-project.org" target="_blank">r-sig-geo@r-project.org</a> <<a href="mailto:r-sig-geo@r-project.org" target="_blank">r-sig-geo@r-project.org</a>><br>
<b>Subject:</b> Re: [R-sig-Geo] unexpected attribute plotting with sf polygons</font>
<div> </div>
</div>
<div>
<div style="text-align:center; padding-top:10px; padding-bottom:10px; display:block; background-color:rgb(247,227,204); border-left:8px solid rgb(215,118,0); font-size:1.15rem; font-family:Arial">
Check twice before you click! This email originated from outside PNNL.</div>
<br>
<div>
<div dir="ltr">
<div style="font-family:arial,sans-serif; font-size:small">You have defined two attributes that are constant across your geometries, so they are shown in the same color. </div>
<div style="font-family:arial,sans-serif; font-size:small">The code `mat <- matrix(c(rep(1, 2), rep(2, 2)), byrow=FALSE, ncol=1)` will define one attribute with two distinct values that will be shown in two colors. </div>
<div style="font-family:arial,sans-serif; font-size:small">Hope this helps!</div>
</div>
<br>
<div>
<div dir="ltr">On Fri, Sep 27, 2024 at 4:37 PM Waichler, Scott R via R-sig-Geo <<a href="mailto:r-sig-geo@r-project.org" target="_blank">r-sig-geo@r-project.org</a>> wrote:<br>
</div>
<blockquote style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
Hi, When I plot the "sf" and "data.frame" object my.poly2 below, all of the polygons are the same color, despite my setting two different values for the Attribute. What have I done wrong?<br>
<br>
my.text <-<br>
c("POLYGON ((0 2.69, 4.483057 2.86, 4.483057 2.76, 0 2.59, 0 2.69))",<br>
"POLYGON ((0 2.59, 4.483057 2.76, 4.483057 2.26, 0 2.09, 0 2.59))",<br>
"POLYGON ((0 2.09, 4.483057 2.26, 4.483057 1.26, 0 1.09, 0 2.09))",<br>
"POLYGON ((0 1.09, 4.483057 1.26, 4.483057 -0.74, 0 -0.91, 0 1.09))")<br>
my.poly <- st_as_sfc(my.text)<br>
mat <- matrix(c(rep(1, 4), rep(2, 4)), byrow=F, ncol=2)<br>
my.poly2 <- st_sf(Attribute = mat, geom = my.poly)<br>
plot(my.poly2, breaks = c(0.5, 1.5, 2.5))<br>
<br>
Thank you,<br>
<br>
Scott Waichler, PhD<br>
<br>
Pacific Northwest National Lab<br>
<br>
<br>
<br>
[[alternative HTML version deleted]]<br>
<br>
_______________________________________________<br>
R-sig-Geo mailing list<br>
<a href="mailto:R-sig-Geo@r-project.org" target="_blank">R-sig-Geo@r-project.org</a><br>
<a href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" originalsrc="https://stat.ethz.ch/mailman/listinfo/r-sig-geo" shash="Jn86uSbGSrwaJ9yBBQ0c22vKYO0AxD8ka/6zoc1CxKmlMdOcAlP+JaPiCIPL1P6fOFEpS+cp4bgZEenQ1gQLqnWwlIExrOmoULdZnDMDxbhV0XyYUD8NSuenvfv73h+7WUoF/4q7OIdjtBGv2LMWgrTUMCdv4VnGSiy2sb+owts=" rel="noreferrer" target="_blank">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a><br>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>