Metropolitan-Council / councilR

A curated collection of commonly used templates, color palettes, functions, and more!
Other
6 stars 1 forks source link

Bug when reading geopackage with missing CRS #72

Open eroten opened 6 months ago

eroten commented 6 months ago

Cannot read in geopackage with ambiguous CRS

library(councilR)

# error when using import_from_gpkg()
councilR::import_from_gpkg("https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dot/trans_aadt_traffic_count_locs/gpkg_trans_aadt_traffic_count_locs.zip")
#> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
#> Message 1: Non-conformant content for record 1 in column FROM_DATE, 1993/01/01,
#> successfully parsed
#> Warning in CPL_crs_from_input(x): GDAL Error 1: PROJ:
#> proj_create_from_database: Cannot find proj.db
#> Error in eval(expr, envir, enclos): crs not found: is it missing?

# no error when manually downloaded
tmp_dir <- tempdir()
tmp_file <- tempfile()
download.file("https://resources.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_dot/trans_aadt_traffic_count_locs/gpkg_trans_aadt_traffic_count_locs.zip",
              destfile = tmp_file)
unzip(tmp_file, exdir = tmp_dir)
list.files(tmp_dir)
#> [1] "file5a971737488d"                   "file5a972e7c2ce3"                  
#> [3] "metadata"                           "trans_aadt_traffic_count_locs.gpkg"
sf::read_sf(paste0(tmp_dir, "/trans_aadt_traffic_count_locs.gpkg"))
#> Warning in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, : GDAL
#> Message 1: Non-conformant content for record 1 in column FROM_DATE, 1993/01/01,
#> successfully parsed
#> Simple feature collection with 39129 features and 14 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 190303.4 ymin: 4816318 xmax: 749460.7 ymax: 5467040
#> Projected CRS: NAD83 / UTM zone 15N
#> # A tibble: 39,129 × 15
#>    SEQUENCE_N FROM_DATE  TO_DATE    ROUTE_LABE STREET_NAM LOCATION_D  VEHICLE_CL
#>         <dbl> <date>     <date>     <chr>      <chr>      <chr>            <dbl>
#>  1          1 1993-01-01 4000-01-01 MN 18      <NA>       E OF MN 65        9154
#>  2          4 1993-01-01 4000-01-01 MN 65      <NA>       N OF MN 18        9153
#>  3          9 1998-01-01 4000-01-01 MN 47      <NA>       N of 215th…          0
#>  4         13 1994-01-01 4000-01-01 US 169     <NA>       SW OF CSAH…       8192
#>  5         14 1994-01-01 4000-01-01 MN 18      <NA>       W OF CSAH …       8193
#>  6         16 1994-01-01 4000-01-01 US 169     <NA>       SW OF 437T…       8194
#>  7         17 1998-01-01 4000-01-01 MN 27      <NA>       E OF MN 65           0
#>  8         20 1998-01-01 4000-01-01 MN 65      <NA>       N OF CR 57…          0
#>  9         21 1998-01-01 4000-01-01 MN 65      <NA>       S OF CSAH …          0
#> 10         22 1995-01-01 4000-01-01 MN 47      <NA>       E OF CSAH …          0
#> # ℹ 39,119 more rows
#> # ℹ 8 more variables: DAILY_FACT <chr>, SEASONAL_F <chr>, AXLE_FACTO <chr>,
#> #   CURRENT_YE <dbl>, CURRENT_VO <dbl>, AADT_COMME <chr>, DATA_TYPE <chr>,
#> #   geom <POINT [m]>

Created on 2024-01-04 with reprex v2.0.2