I downloaded a few shapefiles but they're in EPSG:4326 and I need them in EPSG:3857. Is there a way to convert/save these files using PyQGIS?

  • 2
    Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq. – underdark Mar 19 '16 at 19:20
  • 2
    In order to change the projection of your layer you could just use the option « save as » and select a new projection. – Laurent Robitaille-Lainesse Mar 19 '16 at 21:25

You can use the Reproject Layer algorithm from the processing toolbox.

Let's assume you have a cities.shp in a folder named testing, and you want to create a new file cities_prj.shp that is transformed into EPSG:3857, then this would do it:

import processing

processing.runalg("qgis:reprojectlayer", r"D:\testing\cities.shp", "epsg:3856", r"D:\testing\cities_prj.shp")
  • 1
    @Complete_GIS_noob, if this answer solved your problem then please consider upvoting and accepting it by clicking the greyed out tick next to this answer. This could help other people with the same issues. – user35594 Jul 5 '16 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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