NewGraphEnvironment / fish_passage_peace_2023_reporting

https://newgraphenvironment.github.io/fish_passage_peace_2023_reporting/
Creative Commons Zero v1.0 Universal
0 stars 2 forks source link

williston bull trout shapefiles corrupt #64

Closed NewGraphEnvironment closed 2 months ago

NewGraphEnvironment commented 2 months ago

looks like not just an R issue as won't load (see Invalid Data Source warning)

image

Seems to be a Z dimension (elevation) issue potentially due to a mix of some Z mulitline strings and some not. Tip off was error when trying to plot in R

> path_stub <- "~/Library/CloudStorage/OneDrive-Personal/Projects/2024-073-sern-peace/data/bulltrout_williston"
> filename_spawn <- "BT_Williston_critical_spawning_segments_230112.shp"
> path <- fs::path(path_stub, filename_spawn)
> bt_spawn <- sf::st_read(path) 
Reading layer `BT_Williston_critical_spawning_segments_230112' from data source 
  `/Users/airvine/Library/CloudStorage/OneDrive-Personal/Projects/2024-073-sern-peace/data/bulltrout_williston/BT_Williston_critical_spawning_segments_230112.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 110 features and 37 fields
Geometry type: MULTILINESTRING
Dimension:     XY, XYZ
Bounding box:  xmin: 926382 ymin: 1073716 xmax: 1280647 ymax: 1406620
z_range:       zmin: 0 zmax: 1573
Projected CRS: NAD83 / BC Albers
> # plot with ggplot2
> ggplot(bt_spawn) +
+   geom_sf()  
Error in `geom_sf()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error in `scan()`:
! scan() expected 'a real', got 'ParseException:'
Run `rlang::last_trace()` to see where the error occurred.
There were 50 or more warnings (use warnings() to see the first 50)
Error in `geom_sf()`:
! Problem while converting geom to grob.
ℹ Error occurred in the 1st layer.
Caused by error:
! ParseException: Unknown WKB type 331

Workaround is to remove the Z dimension with sf::st_zm()

NewGraphEnvironment commented 2 months ago

See full script with solution here https://github.com/NewGraphEnvironment/fish_passage_peace_2023_reporting/issues/63