Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on February 10, 2022 9:44PM
Likes: 1
Replies: 6
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:
easting | northing |
521508 | 193079 |
535379 | 180783 |
529701 | 170398 |
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
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
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
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
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.
And in case it helps anyone else, I found that if I checked the "Use a real Python process (instead of Jython)" that worked.
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.