1

How do I get utm data converted into wgs84 all within Python27?

Does anyone know how to import the QGIS Lyon 'reproject' tool I to Python27?

I have a Python script that writes utm Into a text file but I require it to write wgs84 lats and longs instead. All I need (I think) is a module that outputs lats and longs before getting written to the file.

I tried to install Proj and matplotlib and other suggested solutions I found online but the imports seem to fail. I need guidance how to do this successfully but that's for another question.

I have QGIS Lyon installed and I am familiar with reprojecting layers into wgs84 using the reproject tool built in. I know that it works and therefore there is something on my pc that does what I want to achieve. I am hoping that I'm able to simply import the module that is used in QGIS reproject tool.

4
  • Perhaps an answer from this post might help: How to convert from UTM to LatLng in python or Javascript
    – Joseph
    Mar 17, 2016 at 15:53
  • That looks like it's the answer. Thank you for that reference. I'm struggling to figure out how to import GDAL so I can get the osr, Proj and other modules working. I feel like I'm being led on a wild goose chase, downloading various things and following steps that don't work for me.
    – LHo
    Mar 18, 2016 at 1:49
  • I'm currently using this for guidance: github.com/OSGeo/proj.4 and in the README at the bottom of the page is has notes. Where it says the following, where do you type this: If this default path prefix is proper, then execute: ./configure If another path prefix is required, then execute: ./configure --prefix=/my/path Also, how do you execute this where it says: After executing configure, execute: make make install Thirdly, how do I know if I have the VC++ environment variables, and path setup properly?
    – LHo
    Mar 18, 2016 at 2:01
  • 1
    The "INSTALL" text file contains a more generic description on how to install it. I believe you would need to use the OSGeo4W Shell command prompt program (which you can get by installing QGIS via the OSGeo4W Installer) but I'm not completely certain. Hopefully others can also advise :)
    – Joseph
    Mar 18, 2016 at 9:51

1 Answer 1

1

Thank you Joseph. Using the OSGeo4W to run my .py script worked beautifully. Everything imported just fine. To do this, I had to copy the script into the same directory as the OSGeo4W command shell. Also, I wanted to create a file from the script but I couldn't write it in the same directory due to an "access denied" error. So, I just had to change the code to write the file to another location on C:\Users\My Name\Desktop

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.