Summary
The current-country test in gvs_geovalidity() (R/GVS_local.R, merged to main in #2) is strict equality: a record is geovalid only if the GADM country its coordinate falls in equals its declared country. That catches coordinate errors, but it also rejects records whose coordinates are correct and whose country label is wrong. The two failure modes need different treatment, and telling them apart needs its own algorithm.
For now the strict test is being kept deliberately (it matches BIEN's is_geovalid semantics). This issue records the evidence and the candidate approaches so it can be designed properly later.
Evidence
From the garden-variety-traits occurrence pipeline, using the offline GVS raster index (GADM 4.1, 30 arc-seconds), on 37,252,096 GBIF records from 5 of 64 species buckets:
|
records |
share |
| flagged by the strict GADM test |
102,477 |
0.275% |
flagged by GBIF's own COUNTRY_COORDINATE_MISMATCH |
34,858 |
0.094% |
| both |
14,715 |
|
| strict test only |
87,762 |
|
| GBIF only |
20,143 |
|
The strict test flags about 2.9 times as many records as GBIF. The excess is not noise. The twelve most frequent strict-only pairs (declared country, then the country the coordinate falls in) are all neighbouring countries, and together they account for 83.5% of the excess:
| declared |
located |
records |
| NLD |
BEL |
28,583 |
| DEU |
AUT |
10,903 |
| ISR |
PSE |
7,401 |
| ESP |
FRA |
6,190 |
| NLD |
DEU |
5,394 |
| FRA |
ITA |
2,626 |
| HKG |
CHN |
2,572 |
| FRA |
CHE |
2,568 |
| DEU |
CZE |
2,122 |
| DEU |
FRA |
2,049 |
| ESP |
AND |
1,511 |
| FRA |
ESP |
1,380 |
This is the signature of correct coordinates carrying a loose country label, for example a platform's or observer's country attached to a cross-border observation, rather than of coordinate errors. Swapped or negated coordinates usually land far from the declared country, often on another continent. Strict equality therefore discards valid data, concentrated in some of the best-sampled regions.
Related observations
- Boundary cells. Raster-only location (
gpkg = NULL) cannot verify the country of a point in a boundary cell: gvs_locate_current() reports "raster (boundary cell, not verified)". About 21% of records fall on a GADM level-2 boundary cell, although most of those are internal county borders where the country is not in doubt.
- Different boundaries. GBIF flags 6,912 records that the GADM lookup places inside the declared country, presumably because GBIF uses different boundary data.
- Non-ISO3 GADM codes. GADM has 16
gid_0 codes that are not ISO3: the disputed Kashmir zones Z01 to Z09 (attributed to India, China or Pakistan), ZNC Northern Cyprus, XKO Kosovo, XAD Akrotiri and Dhekelia, XSP and XPI (Spratly and Paracel Islands), XCL Clipperton and XCA Caspian Sea. Without explicit handling, every record declared India that falls in a Kashmir zone would be flagged. The pipeline currently treats these codes as untestable.
- Circular declarations. GBIF sometimes fills the country in from the coordinates (
COUNTRY_DERIVED_FROM_COORDINATES, about 0.73% of records). Testing such a country against the same coordinate is circular, so these records should be treated as untestable, not valid.
Candidate approaches (not decided)
- Adjacency exemption. Flag a record only when the located country is neither the declared country nor one of its neighbours. It needs no geometry, since a neighbours table can be derived from the existing index raster, but it is also lenient toward points deep inside a neighbouring country.
- Distance tolerance. Flag a record only when it lies more than X km from the declared country. More precise, but it needs GADM geometry and exact distances.
- Dataset-level diagnosis. A dataset whose mismatches point systematically at one neighbour is probably mislabelled rather than mis-georeferenced. This has the strongest principled basis, but needs dataset keys the service does not currently receive.
- Exact point-in-polygon for boundary-cell mismatches only. The subset is small, so this is cheap even with the geopackage, and it removes the raster ambiguity whichever of the above is chosen.
Whatever is chosen should probably return why a record failed (mislocated, mislabelled, unverifiable), not just a boolean, so that users can choose their own tolerance.
Summary
The current-country test in
gvs_geovalidity()(R/GVS_local.R, merged tomainin #2) is strict equality: a record is geovalid only if the GADM country its coordinate falls in equals its declared country. That catches coordinate errors, but it also rejects records whose coordinates are correct and whose country label is wrong. The two failure modes need different treatment, and telling them apart needs its own algorithm.For now the strict test is being kept deliberately (it matches BIEN's
is_geovalidsemantics). This issue records the evidence and the candidate approaches so it can be designed properly later.Evidence
From the garden-variety-traits occurrence pipeline, using the offline GVS raster index (GADM 4.1, 30 arc-seconds), on 37,252,096 GBIF records from 5 of 64 species buckets:
COUNTRY_COORDINATE_MISMATCHThe strict test flags about 2.9 times as many records as GBIF. The excess is not noise. The twelve most frequent strict-only pairs (declared country, then the country the coordinate falls in) are all neighbouring countries, and together they account for 83.5% of the excess:
This is the signature of correct coordinates carrying a loose country label, for example a platform's or observer's country attached to a cross-border observation, rather than of coordinate errors. Swapped or negated coordinates usually land far from the declared country, often on another continent. Strict equality therefore discards valid data, concentrated in some of the best-sampled regions.
Related observations
gpkg = NULL) cannot verify the country of a point in a boundary cell:gvs_locate_current()reports"raster (boundary cell, not verified)". About 21% of records fall on a GADM level-2 boundary cell, although most of those are internal county borders where the country is not in doubt.gid_0codes that are not ISO3: the disputed Kashmir zones Z01 to Z09 (attributed to India, China or Pakistan), ZNC Northern Cyprus, XKO Kosovo, XAD Akrotiri and Dhekelia, XSP and XPI (Spratly and Paracel Islands), XCL Clipperton and XCA Caspian Sea. Without explicit handling, every record declared India that falls in a Kashmir zone would be flagged. The pipeline currently treats these codes as untestable.COUNTRY_DERIVED_FROM_COORDINATES, about 0.73% of records). Testing such a country against the same coordinate is circular, so these records should be treated as untestable, not valid.Candidate approaches (not decided)
Whatever is chosen should probably return why a record failed (mislocated, mislabelled, unverifiable), not just a boolean, so that users can choose their own tolerance.