Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

R script package tigris: cannot load shapefiles

I am using R script to make a choropleth map visualization. The actual data is confidential, so I cannot show the entire code, but the error comes when I load the shapefiles using 'tigris' package. Power BI Desktop does execute the entire code and makes a beautiful map, but when I publish it to Web, it gives me an error message saying "Error: Download failed; check your internet connection or the status of the Census Bureau website at http://www2.census.gov/geo/tiger/."

All the packages I used in the code are supported by Power BI. Could I get help on how to solve this issue?

 

Here is my code:

 

df_state <- dataset

library(dplyr)
library(tidyr)
library(tidyverse)
library(sf)
library(tmap)

# Downloading a shape file via tigris package
library(tigris) #For downloading the zipcode map
library(curl)
library(httr)
options(tigris_use_cache = TRUE)
geo <- st_as_sf(zctas(cb = TRUE, starts_with = df_state$ZCTA)) 
co <- st_as_sf(counties("California", cb = TRUE)) 
co = st_transform(co , st_crs(geo))

#Merging data & map
df_state.sf = merge(geo, df_state) 

tmap_mode("plot")
tm_shape(co) + tm_borders()

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

Has your problem been solved? If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out. Thanks in advance.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Hi @Anonymous ,

 

This problem can arise when Census blocks connections to its website intermittently. 

Refer this document , you, or your administrator, may need to update your firewall to allow access to the URLs Bing uses for geocoding. Those URLs are:

vtangjiemsft_0-1669950945012.png

You can also refer to the following documentation to try other ways to make a choropleth map visualization :

R Error downloading shapefiles using Tigris · Issue #72 · walkerke/tigris · GitHub

Choropleth map with R – the R Graph Gallery (r-graph-gallery.com)

How to create geographic maps in Power BI using R (sqlshack.com)

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution to help the other members find it more quickly. 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.

Top Kudoed Authors