Discover this year's submissions to the Dataiku Frontrunner Awards and give kudos to your favorite use cases and success stories!READ MORE

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

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

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

0 Kudos
6 Replies
HarizoR
Developer Advocate
Developer Advocate

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
Level 2
Author

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

0 Kudos
milhouse
Level 2
Author

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

0 Kudos
milhouse
Level 2
Author

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. 

0 Kudos
Manuel
Dataiker
Dataiker

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.

0 Kudos
milhouse
Level 2
Author

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

0 Kudos

Labels

?
Labels (2)
A banner prompting to get Dataiku