I know this is a very specific question about a specific package but I can't seem to be able to deal with it on my own so I'm seeking help. I'd like to use the {leaidr} package (GitHub - ivelasq/leaidr: An R Package for U.S. School District Shapefiles) to download shapefiles for US school districts and have followed the instructions written by Isabella here (%>% dreams - An even easier-to-use R package for school district shapefiles) but I can't seem to get it to work. Specifically, when I download the shapefile for a particular state using the lea_get function as she did, I got the following output
trying URL 'https://github.com/datalorax/us-district-shapefiles/raw/master/individ-districts/47.dbf'
Content type 'application/octet-stream' length 210592 bytes (205 KB)
downloaded 205 KB
trying URL 'https://github.com/datalorax/us-district-shapefiles/raw/master/individ-districts/47.prj'
Content type 'text/plain; charset=utf-8' length 147 bytes
downloaded 147 bytes
trying URL 'https://github.com/datalorax/us-district-shapefiles/raw/master/individ-districts/47.shp'
Content type 'application/octet-stream' length 7345380 bytes (7.0 MB)
downloaded 7.0 MB
trying URL 'https://github.com/datalorax/us-district-shapefiles/raw/master/individ-districts/47.shx'
Content type 'application/octet-stream' length 1364 bytes
downloaded 1364 bytes
Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv, :
Cannot open layer
In addition: Warning messages:
1: OGR support is provided by the sf and terra packages among others
2: OGR support is provided by the sf and terra packages among others
Essentially there is a "cannot open layer error" toward the end that I can't deal with. Any help would be greatly appreciated. Thank you!
library(leaidr)
tn <- lea_get("tn")
# Warning: OGR support is provided by the sf and terra packages among others
# Warning: OGR support is provided by the sf and terra packages among others
# Warning: OGR support is provided by the sf and terra packages among others
# Warning: OGR support is provided by the sf and terra packages among others
# Warning: OGR support is provided by the sf and terra packages among others
# Warning: OGR support is provided by the sf and terra packages among others
# OGR data source with driver: ESRI Shapefile
# Source: "/tmp/RtmpAxM7Cb/47", layer: "47"
# with 158 features
# It has 18 fields
str(tn)
# Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
# ..@ data :'data.frame': 158 obs. of 18 variables:
# .. ..$ STATEFP : chr [1:158] "47" "47" "47" "47" ...
# .. ..$ ELSDLEA : chr [1:158] NA NA NA NA ...
[...]
# ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slot
# .. .. ..@ projargs: chr "+proj=longlat +ellps=GRS80 +no_defs"
# .. .. ..$ comment: chr "GEOGCRS[\"GRS 1980(IUGG, 1980)\",\n DATUM[\"D_unknown\",\n ELLIPSOID[\"GRS80\",6378137,298.257222101,"| __truncated__
# ..$ comment: chr "TRUE"
So this works great, and I was able to get the data and do things to them. I do still want to be able to learn how to do things automatically remotely without downloading the shapefiles first though. Do you know what might have happened when I tried the original approach? In the instructions written by the author of the package, she said one must have a GITHUB_PAT before you can run lea_get, which I do. Essentially what I did is the following:
I created a PAT
I used the {gitcreds} package to set my PAT in my environment
Then I ran lea_get but still got the same "cannot open layer" error message as before.