You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用tigris::counties()提取县数据突发错误,求解决方案

问题描述

此前正常运行的代码,近期调用tigris::counties()时突然报错。

执行代码:

require(tigris)
counties_VT <- counties(state="VT",cb=T,class="sf")

报错信息:

Retrieving data for the year 2020
Error: Cannot open "C:\Users\QSMITH\AppData\Local\Temp\RtmpYZZH4z"; The source could be corrupt or not supported. See `st_drivers()` for a list of supported formats.
In addition: Warning message:
In unzip(file_loc, exdir = tmp) : error 1 in extracting from zip file
解决办法
  • 清理临时文件:手动删除报错中指定的临时目录C:\Users\QSMITH\AppData\Local\Temp\RtmpYZZH4z,重启R后重新运行代码。临时文件损坏是这类报错的常见诱因。
  • 更新相关包:运行update.packages(c("tigris", "sf")),旧版本包可能存在数据下载、解压的兼容问题。
  • 指定其他年份:尝试调用不同年份的地理数据,比如counties(state="VT", cb=T, class="sf", year=2023),2020年的数据源可能出现了访问或文件损坏问题。
  • 检查解压工具:确保系统默认解压工具可正常工作,或安装第三方解压软件(如7-Zip)并设置为默认,R调用的解压工具异常会导致解压失败。
  • 手动加载数据:从US Census Bureau官网手动下载佛蒙特州counties的shp压缩包,解压后用sf::st_read()直接加载到R中,绕过tigris的自动下载流程。

内容的提问来源于stack exchange,提问作者Quinterpret

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 20:02:48