| 162 | |
| 163 | {{{ |
| 164 | |
| 165 | /* |
| 166 | CHECKING FOR SPATIAL DUPLICATES |
| 167 | */ |
| 168 | |
| 169 | |
| 170 | --select * from wrbd.stationdbeel s1 join ireland.stations S2 on st_dwithin(s1.the_geom,s2.the_geom,100); |
| 171 | --select distinct on (locationcode) op_id, locationcode from wrbd.stationdbeel s1 join ireland.stations S2 on st_dwithin(s1.the_geom,s2.the_geom,20); |
| 172 | -- first step I copy the code of the stations from wrbd.stationdbeel where the stations are less than 20 m apart. These are doubles |
| 173 | alter table ireland.stations add column dbeel_op_id uuid; |
| 174 | update ireland.stations set dbeel_op_id=op_id from ( |
| 175 | select distinct on (locationcode) op_id, locationcode from wrbd.stationdbeel s1 join ireland.stations S2 on st_dwithin(s1.the_geom,s2.the_geom,20))as sub |
| 176 | where sub.locationcode=stations.locationcode; --86 |
| 177 | |
| 178 | --select t.dbeel_op_id, surveyid from ireland.stations t join ireland.survey s on s.locationcode=t.locationcode where t.dbeel_op_id is not null; |
| 179 | -- second step I copy the same code but to the survey file, I'll know that I have a survey located on a station for which I have already entered data |
| 180 | alter table ireland.survey add column dbeel_op_id uuid; |
| 181 | update ireland.survey set dbeel_op_id=sub.dbeel_op_id from ( |
| 182 | select t.dbeel_op_id, surveyid from ireland.stations t join ireland.survey s on s.locationcode=t.locationcode where t.dbeel_op_id is not null) as sub |
| 183 | where sub.surveyid=survey.surveyid;--298 |
| 184 | |
| 185 | select max(op_year) from wrbd.operation_op where op_st_id like '%MI%'; --2009 there might be double indeed |
| 186 | |
| 187 | /* |
| 188 | TODO for the stations that have duplicates, check whether the year has been entered or if there is something we can reckon about the code |
| 189 | */ |
| 190 | }}} |