There's really two issues here:
1. admin.tbl_smp_loc doesn't have a unique constraint on smp_id
This causes issues where we have multiple locations for the same SMP

2. Revise script
Each feature class has its own essentially duplicated script that isn't easily readable. We also want to make sure we're not adding duplicates because it only checks for the smp_id to be existing in the smp_loc table. We should probably remove the non-standard magrittr code:
|
basin <- suppressWarnings((st_read(dsn_infra_pub, "gisad.GSWIBASIN", quiet = TRUE))) %>% |
|
st_set_crs(2272) %>% st_transform(4326) %>% #Convert from PA State Plane to WGS 1984 |
|
st_centroid %>% filter(!is.na(SMP_ID)) %>% transmute(smp_id = gsub("\\s", "", SMP_ID)) %>% |
|
filter(!(grepl("[A-z]", smp_id))) %>% #No A-Z characters permitted. Upper and lower case. |
|
filter(!(smp_id %in% smp_loc$smp_id)) %>% |
|
{data.frame(st_coordinates(.), .$smp_id)} %>% |
|
select(smp_id = 3, lon_wgs84 = 1, lat_wgs84 = 2) |
There's really two issues here:
1.
admin.tbl_smp_locdoesn't have a unique constraint onsmp_idThis causes issues where we have multiple locations for the same SMP
2. Revise script
Each feature class has its own essentially duplicated script that isn't easily readable. We also want to make sure we're not adding duplicates because it only checks for the smp_id to be existing in the smp_loc table. We should probably remove the non-standard magrittr code:
marsMaintenanceScripts/02_connectscripts/08_update_smp_tables.RMD
Lines 129 to 135 in cabf1c9