st_read R 中 shinyapp 的路径
st_read path for shinyapp in R
通常当使用 st_read
时,你将路径放在 dsn
中,但如果你将完整路径放在 dsn
中,它会给出一个错误,因为该文件路径服务器上不存在。所以,现在我将 shapefile 放在 www
文件夹中,但我不知道将什么路径放入 dsn
以便应用程序获取 shapefile。
我该如何解决这个问题?
应用中的当前功能代码:
rocks_utm_sf = st_read(dsn = "D:/Sedimentary_Data_Analysis/www",layer = "Sed_UTM")
日志中的以下错误会破坏应用程序
021-10-02T19:05:08.733697+00:00 shinyapps[4783188]: Server version: 1.8.6.1
2021-10-02T19:05:08.733707+00:00 shinyapps[4783188]: R version: 4.0.2
2021-10-02T19:05:08.733705+00:00 shinyapps[4783188]: LANG: en_US.UTF-8
2021-10-02T19:05:08.725767+00:00 shinyapps[4783188]: Running on host: 52b53ce9aed0
2021-10-02T19:05:08.733716+00:00 shinyapps[4783188]: shiny version: 1.6.0
2021-10-02T19:05:08.733732+00:00 shinyapps[4783188]: httpuv version: 1.6.1
2021-10-02T19:05:08.931183+00:00 shinyapps[4783188]: Using jsonlite for JSON processing
2021-10-02T19:05:08.934357+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.733977+00:00 shinyapps[4783188]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-10-02T19:05:08.733739+00:00 shinyapps[4783188]: rmarkdown version: 2.9
2021-10-02T19:05:08.733790+00:00 shinyapps[4783188]: jsonlite version: 1.7.2
2021-10-02T19:05:08.934357+00:00 shinyapps[4783188]: Starting R with process ID: '26'
2021-10-02T19:05:08.733779+00:00 shinyapps[4783188]: knitr version: 1.33
2021-10-02T19:05:08.963216+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.733791+00:00 shinyapps[4783188]: RJSONIO version: (none)
2021-10-02T19:05:08.733797+00:00 shinyapps[4783188]: htmltools version: 0.5.1.1
2021-10-02T19:05:08.963841+00:00 shinyapps[4783188]: box
2021-10-02T19:05:08.963217+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.963840+00:00 shinyapps[4783188]: The following object is masked from ‘package:graphics’:
2021-10-02T19:05:08.963840+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.963217+00:00 shinyapps[4783188]: Attaching package: ‘shinydashboard’
2021-10-02T19:05:08.963841+00:00 shinyapps[4783188]:
2021-10-02T19:05:10.008023+00:00 shinyapps[4783188]: ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
2021-10-02T19:05:10.013142+00:00 shinyapps[4783188]: ✔ ggplot2 3.3.5 ✔ purrr 0.3.4
2021-10-02T19:05:10.013143+00:00 shinyapps[4783188]: ✔ tibble 3.1.3 ✔ dplyr 1.0.7
2021-10-02T19:05:10.013144+00:00 shinyapps[4783188]: ✔ tidyr 1.1.3 ✔ stringr 1.4.0
2021-10-02T19:05:10.194146+00:00 shinyapps[4783188]: ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
2021-10-02T19:05:10.194148+00:00 shinyapps[4783188]: ✖ dplyr::lag() masks stats::lag()
2021-10-02T19:05:10.013144+00:00 shinyapps[4783188]: ✔ readr 2.0.0 ✔ forcats 0.5.1
2021-10-02T19:05:10.194148+00:00 shinyapps[4783188]: ✖ dplyr::filter() masks stats::filter()
2021-10-02T19:05:10.415161+00:00 shinyapps[4783188]: Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
2021-10-02T19:05:10.464817+00:00 shinyapps[4783188]: Listening on http://127.0.0.1:44842
2021-10-02T19:05:10.464815+00:00 shinyapps[4783188]:
2021-10-02T19:05:16.625537+00:00 shinyapps[4783188]: Warning: Error in : Cannot open "D:/Sedimentary_Data_Analysis/www"; The file doesn't seem to exist.
2021-10-02T19:05:16.630916+00:00 shinyapps[4783188]: 113: <Anonymous>
感谢 Guillaumme 的评论,所以我能够通过首先将 shiny
应用程序移动到 R
项目来解决问题。然后在 app
代码中写入 st_read
如下,当 shapefile 在 shinyapps.io
.
上发布时,应用程序能够获取 shapefile
sf_object = st_read(dsn = "www", layer = "Name")
通常当使用 st_read
时,你将路径放在 dsn
中,但如果你将完整路径放在 dsn
中,它会给出一个错误,因为该文件路径服务器上不存在。所以,现在我将 shapefile 放在 www
文件夹中,但我不知道将什么路径放入 dsn
以便应用程序获取 shapefile。
我该如何解决这个问题?
应用中的当前功能代码:
rocks_utm_sf = st_read(dsn = "D:/Sedimentary_Data_Analysis/www",layer = "Sed_UTM")
日志中的以下错误会破坏应用程序
021-10-02T19:05:08.733697+00:00 shinyapps[4783188]: Server version: 1.8.6.1
2021-10-02T19:05:08.733707+00:00 shinyapps[4783188]: R version: 4.0.2
2021-10-02T19:05:08.733705+00:00 shinyapps[4783188]: LANG: en_US.UTF-8
2021-10-02T19:05:08.725767+00:00 shinyapps[4783188]: Running on host: 52b53ce9aed0
2021-10-02T19:05:08.733716+00:00 shinyapps[4783188]: shiny version: 1.6.0
2021-10-02T19:05:08.733732+00:00 shinyapps[4783188]: httpuv version: 1.6.1
2021-10-02T19:05:08.931183+00:00 shinyapps[4783188]: Using jsonlite for JSON processing
2021-10-02T19:05:08.934357+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.733977+00:00 shinyapps[4783188]: Using pandoc: /opt/connect/ext/pandoc/2.11
2021-10-02T19:05:08.733739+00:00 shinyapps[4783188]: rmarkdown version: 2.9
2021-10-02T19:05:08.733790+00:00 shinyapps[4783188]: jsonlite version: 1.7.2
2021-10-02T19:05:08.934357+00:00 shinyapps[4783188]: Starting R with process ID: '26'
2021-10-02T19:05:08.733779+00:00 shinyapps[4783188]: knitr version: 1.33
2021-10-02T19:05:08.963216+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.733791+00:00 shinyapps[4783188]: RJSONIO version: (none)
2021-10-02T19:05:08.733797+00:00 shinyapps[4783188]: htmltools version: 0.5.1.1
2021-10-02T19:05:08.963841+00:00 shinyapps[4783188]: box
2021-10-02T19:05:08.963217+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.963840+00:00 shinyapps[4783188]: The following object is masked from ‘package:graphics’:
2021-10-02T19:05:08.963840+00:00 shinyapps[4783188]:
2021-10-02T19:05:08.963217+00:00 shinyapps[4783188]: Attaching package: ‘shinydashboard’
2021-10-02T19:05:08.963841+00:00 shinyapps[4783188]:
2021-10-02T19:05:10.008023+00:00 shinyapps[4783188]: ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.1 ──
2021-10-02T19:05:10.013142+00:00 shinyapps[4783188]: ✔ ggplot2 3.3.5 ✔ purrr 0.3.4
2021-10-02T19:05:10.013143+00:00 shinyapps[4783188]: ✔ tibble 3.1.3 ✔ dplyr 1.0.7
2021-10-02T19:05:10.013144+00:00 shinyapps[4783188]: ✔ tidyr 1.1.3 ✔ stringr 1.4.0
2021-10-02T19:05:10.194146+00:00 shinyapps[4783188]: ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
2021-10-02T19:05:10.194148+00:00 shinyapps[4783188]: ✖ dplyr::lag() masks stats::lag()
2021-10-02T19:05:10.013144+00:00 shinyapps[4783188]: ✔ readr 2.0.0 ✔ forcats 0.5.1
2021-10-02T19:05:10.194148+00:00 shinyapps[4783188]: ✖ dplyr::filter() masks stats::filter()
2021-10-02T19:05:10.415161+00:00 shinyapps[4783188]: Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
2021-10-02T19:05:10.464817+00:00 shinyapps[4783188]: Listening on http://127.0.0.1:44842
2021-10-02T19:05:10.464815+00:00 shinyapps[4783188]:
2021-10-02T19:05:16.625537+00:00 shinyapps[4783188]: Warning: Error in : Cannot open "D:/Sedimentary_Data_Analysis/www"; The file doesn't seem to exist.
2021-10-02T19:05:16.630916+00:00 shinyapps[4783188]: 113: <Anonymous>
感谢 Guillaumme 的评论,所以我能够通过首先将 shiny
应用程序移动到 R
项目来解决问题。然后在 app
代码中写入 st_read
如下,当 shapefile 在 shinyapps.io
.
sf_object = st_read(dsn = "www", layer = "Name")