문제

R의 GGMAP 라이브러리를 사용하여 애틀랜타 지역의지도를 제작하고 있습니다. 코드를 실행할 때는 맵과 다른 레이어에 포인트를 표시 할 수 있지만 PDF 이외의 그래픽 장치에서 맵 자체를 인쇄 할 수 없습니다. 문제없이 다른 컴퓨터 에서이 코드를 사용할 수 있으므로 구성 문제가 의심되지만 다른 두 컴퓨터는 단순히 빈 플롯을 표시합니다.

다음은 코드의 스케일 다운 버전입니다. 빈 플롯이 재현 할 수 없다고 가정하지만 구성 문제가 어디에 있는지에 대한 지침을 얻고 싶습니다.

library('ggplot2')
library('ggmap')
library('mapproj')

# ggmapTemp.png gets saved to the working directory correctly
atlanta <- get_map(location=c(lon=-84.26039,
                              lat=33.8751),
                   zoom=9,maptype='roadmap')

atlantaMap <- ggmap(atlanta, extent = 'device', legend = 'topleft')

# this produces a blank plot from both RStudio as well as R
atlantaMap

# this produces the actual map correctly
pdf("plot.pdf")
atlantaMap
dev.off()

# this produces a png file with only a white background
png("plot.png")
atlantaMap
dev.off()

세션 정보 :

R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] mapproj_1.2-1    ggmap_2.3        ggplot2_0.9.3.1  maps_2.3-6       maptools_0.8-27 
 [6] sp_1.0-14        car_2.0-19       reshape2_1.2.2   plyr_1.8         Revobase_6.2.0  
[11] RevoMods_6.2.0   RevoScaleR_6.2.0 lattice_0.20-13  rpart_4.1-0     

loaded via a namespace (and not attached):
 [1] codetools_0.2-8     colorspace_1.2-4    dichromat_2.0-0     digest_0.6.3        foreach_1.4.0      
 [6] foreign_0.8-52      grid_2.15.3         gtable_0.1.2        iterators_1.0.6     labeling_0.2       
[11] MASS_7.3-23         munsell_0.4.2       nnet_7.3-5          png_0.1-6           proto_0.3-10       
[16] RColorBrewer_1.0-5  RgoogleMaps_1.2.0.5 rjson_0.2.13        RJSONIO_1.0-3       scales_0.2.3       
[21] stringr_0.6.2       tools_2.15.3   

및 기능 :

jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets   libxml     fifo   cledit 
TRUE     TRUE     TRUE     TRUE    FALSE    FALSE     TRUE     TRUE     TRUE    FALSE     TRUE 
iconv      NLS  profmem    cairo 
TRUE     TRUE     TRUE     TRUE 
도움이 되었습니까?

해결책

문제는 서버가 연결을 통해 전달되는 비트 깊이를 제한하는 것과 관련이 있습니다. 신탁 문제와 해결책을 문서화합니다 그들의 사이트에서 :

원격 데스크탑 세션에서 색 깊이를 결정하는 디스플레이 변수를 포함한 모든 환경 변수는 RCP-TCP 연결 설정에 의해 결정됩니다. 예를 들어, 사용자는 느린 연결을 통해 연결할 때 색 깊이를 줄일 수 있습니다. 다른 설정은 픽셀 당 15 비트, 16 비트, 24 비트 또는 32 비트입니다. 원격 데스크탑 색상 깊이를 높이려면 :

Windows 서버에서 액세서리 메뉴에서 원격 데스크톱 세션 호스트 구성을 시작하십시오. 연결에서 RDP-TCP를 마우스 오른쪽 버튼으로 클릭하고 속성을 선택하십시오. 클라이언트 설정 탭에서 한계를 선택 취소하거나 컬러 깊이를 선택하지 않거나 픽셀 당 32 비트로 설정하십시오.

"최대 색상 깊이 제한"확인란을 선택 취소하고 서버에 다시 연결하면 래스터 맵 배경이 예상대로 나타납니다. 또한 대체 장치에 출력하는 옵션 2를 제공합니다.

다른 팁

Jrshrenk는 R과 패키지를 한동안 업데이트하지 않은 것 같습니다. 이론적으로 R, GGMAP, PNG 및 GGPLOT2 버전은 충분 해 보이지만.

    Package: ggmap
    Version: 2.4
    Depends: R (>= 2.14.0), ggplot2 (>= 0.9.2)
    Imports: proto, scales, RgoogleMaps, png, plyr, reshape2, grid, rjson,
            mapproj, jpeg, geosphere, digest
    Suggests: MASS, stringr
        License: GPL-2
        NeedsCompilation: no

    Package: png
    Version: 0.1-7
    Depends: R (>= 2.9.0)
    License: GPL-2 | GPL-3
    NeedsCompilation: yes

R과 패키지를 업데이트하여 문제를 해결하는지 확인하려고합니다.

#Save your current packages but not the base ones:
savepackages <- rownames(installed.packages(priority='NA')) 
write(savepackages, file="listpackages.txt")

#Check for Updates of R
library(installr)
check.for.updates.R(notify_user = TRUE, use_GUI = TRUE,
                    page_with_download_url = "http://cran.rstudio.com/bin/windows/base/",
                    pat = "R-[0-9.]+-win")

#Download and Install New Version
install.R(page_with_download_url = "http://cran.rstudio.com/bin/windows/base/",
          pat = "R-[0-9.]+-win.exe", to_checkMD5sums = TRUE,
          keep_install_file = TRUE, download_dir = tempdir(), silent = FALSE)

#Then reinstall packages 
pkg.ls <- read.table("listpackages.txt")
install.packages(pkg.ls)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top