Converting OSGB36 coordinates (Eastings and Northings) to WGS84 Lat Longs?

Options
milhouse
milhouse Registered Posts: 5 ✭✭✭

Hi All,

I have a dataset with columns with Eastings and Northings in the Ordnance Survey OSGB36 National Grid (https://spatialreference.org/ref/epsg/27700/). I'd like to convert these to Latlongs (WGS84) and was wondering if there was a way to do that with a built in Dataiku function? I had a look at the coordinate reference system conversion processor and it looks like the input data needs to be in degrees. The OSGB data looks like this:

eastingnorthing
521508193079
535379180783
529701170398
525312 178385


If not, does anyone have a reliable python (or other) script to do the conversion? I've done a bit of Googling but not found a definitive way of calculating it, and the maths is definitely beyond me.

Thanks!
Steven


Operating system used: MacOS

Answers

  • HarizoR
    HarizoR Dataiker, Alpha Tester, Registered Posts: 138 Dataiker
    Options

    Hi Steven,

    There is an open-source Python package called convertbng that may suit your needs. You can install it using code environments and then leverage it in any of your Python code (recipes, notebooks, etc.).

    Hope this helps!

    Best,

    Harizo

  • milhouse
    milhouse Registered Posts: 5 ✭✭✭
    Options

    Thanks Harizo! I'll read up the documentation on code environments, I've not used Python scripts in DSS yet, but this gives me the hint I needed!

    Steven

  • milhouse
    milhouse Registered Posts: 5 ✭✭✭
    Options

    So I created a code environment and installed the convertbng module, and have confirmed that the module was successfully installed to the code environment. I believe this is set at the DSS level, not the project level?
    When I return to my project, is there something I need to do to let it know which code environment it should use? I'm using a Python code step in a recipe to hopefully run the conversion, but when I try to import the module at the top of the python script and run it, I get the following error:

    Python error : <type 'exceptions.ImportError'> : No module named convertbng.

    Here's the code I tried to add:

    import convertbng

    def process(row):
    lonlat = convertbng.convert_lonlat([row['location_easting_osgr']],[row['location_northing_osgr']])
    return lonlat

    Sorry if I've missed something obvious. I checked the following documentation pages:
    https://doc.dataiku.com/dss/10.0/python/index.html
    https://doc.dataiku.com/dss/10.0/code-envs/operations-python.html

    Thanks,

    Steven

  • milhouse
    milhouse Registered Posts: 5 ✭✭✭
    Options

    Ah, so I found that in the project settings there was a Code env selection option, and configured the environment I'd installed the module to. I was hoping at that point that my recipe step would recognise the module as being installed, but I still get the same error.

  • milhouse
    milhouse Registered Posts: 5 ✭✭✭
    Options

    And in case it helps anyone else, I found that if I checked the "Use a real Python process (instead of Jython)" that worked.

  • Manuel
    Manuel Alpha Tester, Dataiker Alumni, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Core Concepts, Dataiku DSS Adv Designer, Registered Posts: 193 ✭✭✭✭✭✭✭
    Options

    Hi,

    At the recipe level, in the advanced settings, you can also specify which code environment to use for that recipe alone. See the attached image.

    I hope this helps.

Setup Info
    Tags
      Help me…