Closed BryceMcManus-NOAA closed 2 years ago
We have a spatial join in the processing code now, so that might be happening here:
point_geo <- st_as_sf(VTR_DMIS_AC,
coords = c(x = "DDLON", y = "DDLAT"), crs = crs )
or here:
point_geo_lease <- st_as_sf(final_product,
coords = c(x = "DDLON", y = "DDLAT"), crs = crs )
I can see two possible solutions:
Should be pretty easy for us to figure out if this is a .csv problem with is.numeric(MN30SQID)
or stick in a as.numeric()
at the end if it's a deal with the st_as_sf()
I also just noticed we have a permit.y variable, which we should probably get rid of. My guess is that it's the permit number from the VTR_Query section.
For the DDLON/DDLAT issue, I'd say solution 2. From a FishSET perspective, it would be easier if trip location exists as separate numeric columns rather than as a geometry list-column, although I can see the need for FishSET to handle cases like these.
This may be helpful for converting the sf_point geometry to separate lon and lat columns: https://github.com/r-spatial/sf/issues/231
sfc_as_cols <- function(x, names = c("x","y")) {
stopifnot(inherits(x,"sf") && inherits(sf::st_geometry(x),"sfc_POINT"))
ret <- sf::st_coordinates(x)
ret <- tibble::as_tibble(ret)
stopifnot(length(names) == ncol(ret))
x <- x[ , !names(x) %in% names]
ret <- setNames(ret,names)
dplyr::bind_cols(x,ret)
}
Okay, I have a fix coded for DDLAT/DDLON and I'm just making sure it works.
R is telling me that MN30SQID
is numeric, so I'm laying the blame on writing as a csv.
@mchaji : There's a new dataset in /home2/mlee/Effort-Displacement--Scallop/data/main can you forward the final_product_lease csv and .Rds to all via accellion? Thx.
Done, should be able to find the most recent Rds & Csv here: https://sfc.doc.gov/w/f-a36c8ff1-e571-4530-a9c7-cb6448a208fe
Closing this -- code is written and data was sent over.... although @mchaji : can you send the link to data by email. Since we moved the repository into NEFSC, @BryceMcManus-NOAA can't see this.
@mchaji It looks like the trip location columns ("DDLON" and "DDLAT") are either missing or a formatting issue occurred and pushed them into the "geometry" and "MN30SQID" columns as strings.
Library
Read scallop data