walkerke / tigris

Download and use Census TIGER/Line shapefiles in R
Other
324 stars 44 forks source link

`erase_water` fails with `year` 2010, 2011, or 2012 #182

Open Kodiologist opened 9 months ago

Kodiologist commented 9 months ago
> library(tigris)                                                                                                 
To enable caching of data, set `options(tigris_use_cache = TRUE)`                                                 
in your R script or .Rprofile.                                                                                    
> king_tracts <- tracts(state = "WA", county = "King", year = 2020)                                               
Using FIPS code '53' for state 'WA'                      
  |======================================================================| 100%                                   
Using FIPS code '033' for 'King County'
> e2020 = erase_water(king_tracts, area_threshold = 0.9, year = 2020)
Fetching area water data for your dataset's location...
Erasing water area...
If this is slow, try a larger area threshold value.
> e2010 = erase_water(king_tracts, area_threshold = 0.9, year = 2010)
Fetching area water data for your dataset's location...
Error in UseMethod("st_transform") : 
  no applicable method for 'st_transform' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"
> e2011 = erase_water(king_tracts, area_threshold = 0.9, year = 2011)
Warning in unzip(file_loc, exdir = tmp) :
  error 1 in extracting from zip file
Cannot open layer cb_2011_us_county_500k
Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  : 
  Opening layer failed.
> e2012 = erase_water(king_tracts, area_threshold = 0.9, year = 2012)
Warning in unzip(file_loc, exdir = tmp) :
  error 1 in extracting from zip file
Cannot open layer cb_2012_us_county_500k
Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet,  : 
  Opening layer failed.
> e2013 = erase_water(king_tracts, area_threshold = 0.9, year = 2013)
Fetching area water data for your dataset's location...
Erasing water area...
If this is slow, try a larger area threshold value.

Possibly related:

> tigris::area_water(state = "WA", county = "King", year = 2010)
Error: tigris::area_water is not currently available for years prior to 2011.  To request this feature,
                   file an issue at https://github.com/walkerke/tigris.

I'm using tigris 2.0.4 with sf 1.0.7.

elipousson commented 6 months ago

I believe this is the same issue as #172.