Closed cedricbriandgithub closed 2 years ago
The problem occurs because some data in t_eelstock_eel refers to ES_Spai, should be changed to ES_Inne
This creates some duplicates, but this is likely related to NP or NC prefilled data - should check
confirmed by excel, so we can deprecate all ES_Spai data (qal_id = 21) and then associates then with ES_Inne
begin; UPDATE ref.tr_emusplit_ems SET geom = sub.geom FROM (SELECT st_collect(geom) AS geom FROM ref.tr_emusplit_ems WHERE emu_nameshort IN ('ES_Inne', 'ES_Spai')) sub WHERE emu_nameshort = 'ES_Inne'; DELETE FROM ref.tr_emusplit_ems WHERE emu_nameshort = 'ES_Spai';
--merge ES_Spai and ES_Inne polygons UPDATE ref.tr_emu_emu SET geom = sub.geom FROM (SELECT st_union(geom) AS geom FROM ref.tr_emu_emu WHERE emu_nameshort IN ('ES_Inne', 'ES_Spai')) sub WHERE emu_nameshort = 'ES_Inne'; -- deprecate all ES_Spai data update datawg.t_eelstock_eel set eel_qal_id = 21, eel_qal_comment = 'deprecated' where eel_emu_nameshort ='ES_Spai'; -- assign ES_Spai to ES_Inne update datawg.t_eelstock_eel set eel_emu_nameshort ='ES_Inne' where eel_emu_nameshort ='ES_Spai'; --remove ES_Spai DELETE FROM ref.tr_emu_emu WHERE emu_nameshort = 'ES_Spai'; commit;
-- NOT done 2021 there are topological problems when trying to udpate UPDATE ref.tr_emusplit_ems SET geom = sub.geom FROM (SELECT st_collect(geom) AS geom FROM ref.tr_emusplit_ems WHERE emu_nameshort IN ('ES_Inne', 'ES_Spai')) sub WHERE emu_nameshort = 'ES_Inne'; DELETE FROM ref.tr_emusplit_ems WHERE emu_nameshort = 'ES_Spai';
UPDATE ref.tr_emu_emu SET geom = sub.geom FROM (SELECT st_union(geom) AS geom FROM ref.tr_emu_emu WHERE emu_nameshort IN ('ES_Inne', 'ES_Spai')) sub WHERE emu_nameshort = 'ES_Inne'; DELETE FROM ref.tr_emu_emu WHERE emu_nameshort = 'ES_Spai';