Hi everyone Hope you're having a nice weekend! I'm still having trouble with the st_write. It is doing the polygons perfectly, but no fill Color. Use this link to get the data: https://www.dropbox.com/s/c2si2neeu179e8d/sg1.RData?dl=0 load("sg1.RData") library(dplyr) library(leaflet) library(sf) pal1 <- colorBin("YlOrRd",miej.sg$MiEJScreen, bins=c(0,50,60,70,100)) popup1 <- paste( "EJ: ",miej.sg$MiEJScreen,"<br>", "Tract",substring(miej.sg$GEOID,6,11),"<br>", "Zip",miej.sg$zip,"<br>") #Full graph m5a <- leaflet() %>% #addTiles() %>% addPolygons(data=miej.sg,fillColor = ~pal1(miej.sg$MiEJScreen), popup=~popup1, fillOpacity=0.7,weight=2.5,color="#301934",opacity=1) %>% addLegend(pal=pal1,values=miej.sg$MiEJScreen,title="EJ Score", position="bottomright") Now, if I use "st_write", the KML file is produced, but no fill color. st_write(miej.sg,"test1a.kml", fillColor=pal1(miej.sg$MiEJScreen)) I have tried all sorts of combinations with layer_options as well, but no good. Thanks for any help! Sincerely, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com
Back again with KML and st_write
3 messages · Erin Hodgess, Roger Bivand
Hello again
I got a solution at last. I downloaded geoR, RandomFields, landmap, and
plotKML. I got them from the archives.
Anyhow, the solution is not bad using the plotKML package.
pal1 <- colorBin("YlOrRd",miej.sg$MiEJScreen,
bins=c(0,50,60,70,100))
xp <- pal1(miej.sg$MiEJScreen)
plotKML(miej.sg,fill=xp,"erin1b.kml")
So that is a particular solution.
Thanks,
Erin
Erin Hodgess, PhD
mailto: erinm.hodgess at gmail.com
On Sat, Jun 4, 2022 at 11:20 AM Erin Hodgess <erinm.hodgess at gmail.com>
wrote:
Hi everyone Hope you're having a nice weekend! I'm still having trouble with the st_write. It is doing the polygons perfectly, but no fill Color. Use this link to get the data: https://www.dropbox.com/s/c2si2neeu179e8d/sg1.RData?dl=0 load("sg1.RData") library(dplyr) library(leaflet) library(sf) pal1 <- colorBin("YlOrRd",miej.sg$MiEJScreen, bins=c(0,50,60,70,100)) popup1 <- paste( "EJ: ",miej.sg$MiEJScreen,"<br>", "Tract",substring(miej.sg$GEOID,6,11),"<br>", "Zip",miej.sg$zip,"<br>") #Full graph m5a <- leaflet() %>% #addTiles() %>% addPolygons(data=miej.sg,fillColor = ~pal1(miej.sg$MiEJScreen), popup=~popup1, fillOpacity=0.7,weight=2.5,color="#301934",opacity=1) %>% addLegend(pal=pal1,values=miej.sg$MiEJScreen,title="EJ Score", position="bottomright") Now, if I use "st_write", the KML file is produced, but no fill color. st_write(miej.sg,"test1a.kml", fillColor=pal1(miej.sg$MiEJScreen)) I have tried all sorts of combinations with layer_options as well, but no good. Thanks for any help! Sincerely, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com
1 day later
On Sat, 4 Jun 2022, Erin Hodgess wrote:
Hello again
I got a solution at last. I downloaded geoR, RandomFields, landmap, and
plotKML. I got them from the archives.
Anyhow, the solution is not bad using the plotKML package.
pal1 <- colorBin("YlOrRd",miej.sg$MiEJScreen,
bins=c(0,50,60,70,100))
xp <- pal1(miej.sg$MiEJScreen)
plotKML(miej.sg,fill=xp,"erin1b.kml")
So that is a particular solution.
As you note, the archiving of packages has had consequences for packages using them (and further downstream too). sf_write() can write KML files, but GDAL/OGR has two drivers: KML, which is simpler, and LIBKML which requires an extra external library when building GDAL. See https://gdal.org/drivers/vector/kml.html#vector-kml and https://gdal.org/drivers/vector/libkml.html#vector-libkml. However the latest libkml is from December 2015, suggesting that no active development is occurring. plotKML is described in https://www.jstatsoft.org/article/view/v063i05, and does pass R CMD check cleanly, so was probably archived when a package it imported was archived; it could be re-submitted, especially if someone wanted to help the current maintainer. Roger
Thanks, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com On Sat, Jun 4, 2022 at 11:20 AM Erin Hodgess <erinm.hodgess at gmail.com> wrote:
Hi everyone Hope you're having a nice weekend! I'm still having trouble with the st_write. It is doing the polygons perfectly, but no fill Color. Use this link to get the data: https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dropbox.com%2Fs%2Fc2si2neeu179e8d%2Fsg1.RData%3Fdl%3D0&data=05%7C01%7CRoger.Bivand%40nhh.no%7C4fab69fff266422a4f2f08da465ad3c5%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637899653176959245%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=%2BVqWm%2Fxdy37os6Rj8eqirn7O5OKfgcDlVslSvn6Pei4%3D&reserved=0 load("sg1.RData") library(dplyr) library(leaflet) library(sf) pal1 <- colorBin("YlOrRd",miej.sg$MiEJScreen, bins=c(0,50,60,70,100)) popup1 <- paste( "EJ: ",miej.sg$MiEJScreen,"<br>", "Tract",substring(miej.sg$GEOID,6,11),"<br>", "Zip",miej.sg$zip,"<br>") #Full graph m5a <- leaflet() %>% #addTiles() %>% addPolygons(data=miej.sg,fillColor = ~pal1(miej.sg$MiEJScreen), popup=~popup1, fillOpacity=0.7,weight=2.5,color="#301934",opacity=1) %>% addLegend(pal=pal1,values=miej.sg$MiEJScreen,title="EJ Score", position="bottomright") Now, if I use "st_write", the KML file is produced, but no fill color. st_write(miej.sg,"test1a.kml", fillColor=pal1(miej.sg$MiEJScreen)) I have tried all sorts of combinations with layer_options as well, but no good. Thanks for any help! Sincerely, Erin Erin Hodgess, PhD mailto: erinm.hodgess at gmail.com
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=05%7C01%7CRoger.Bivand%40nhh.no%7C4fab69fff266422a4f2f08da465ad3c5%7C33a15b2f849941998d56f20b5aa91af2%7C0%7C0%7C637899653176959245%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rq0m2nMNRHLxHX482T4OGdRHRD7encqyba1X5cXuYvs%3D&reserved=0
Roger Bivand Emeritus Professor Department of Economics, Norwegian School of Economics, Postboks 3490 Ytre Sandviken, 5045 Bergen, Norway. e-mail: Roger.Bivand at nhh.no https://orcid.org/0000-0003-2392-6140 https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en