OS Grid references

hmmm… you’re not saying that it doesn’t work.

what’s wrong with that solution? seems like you have so many available solutions.

you should talk to your iNaturalistUK admins to see if they have any tools that might be even easier, if that’s what you’re looking for.

i was working on some Python code for working with iNaturalist data, and i was going to work on a script next that loads data from CSV files and does some processing on them, but i don’t know when i’ll get around to publishing a version of that. that future thing could be adapted fairly easily to get OS references.

but in the meantime, i think you could adapt my already published notebook for getting observations observations from the API to get some OS Referenced observations. i don’t know that this would be better than sbushes script, though running code on my JupyterLite deployment should be a little faster than going through sbushes’s code in Binder.

the key changes needed to adapt my stuff would be:

  1. add a line to import the needed conversion function:

    from OSGridConverter import latlong2grid
  2. after the line that begins with obs = (in the main execution section), add the following code (based on https://pypi.org/project/OSGridConverter/):

    for o in obs:
    if obs.get('latitude') is not None and obs.get('longitude') is not None:
        g = latlong2grid(obs['latitude'],obs['longitude'])
        obs['os_reference'] = str(g)
        obs['os_reference_east_north'] = f'({g.E},{g.N})'
  3. change the line that sets req_params_string = to whatever you need your observation filter parameters to be.

  4. on the obs = line, set get_all_pages=True so that you’ll get the maximum number of records available from the API.