I am writing a QGIS standalone Python command line tool. I check that all input shapefiles have a valid CRS with
layer.crs().isValid() and then I reproject any files that are not already in ESPG:4326. One input file is originally in EPSG:3338. So, I call:
processing.runalg('qgis:reprojectlayer', input.shp, 'ESPG:4326', reprojectOut.shp)
the output 'reprojectOut.shp' has the correct CRS (4326) and correct .prj file and also displays properly even with 'On The Fly' disabled. So all seems well... until I try to extract a few features from the reprojected shapefile with:
processing.runalg('qgis:extractbyexpression', reprojectOut.shp, expression, extractOut.shp)
and somehow this output 'extractOut.shp' contains the correct features but has gone back to the original 'EPSG:3338' CRS. Is there something I am missing? Is there a reference to the original input file hiding somewhere? I have verified the filepaths are correct and tried passing both direct filepaths and also
QgsVectorLayer() objects as input parameters. I am running QGIS 2.18.13 on Mac OSX High Sierra.