I've created a python standalone script to clip two shapefiles with qgis. I've installed qgis3 with OSgeo4W. The logic is as follows:
import qgis
from qgis.core import *
from qgis.core import QgsApplication
from qgis.core import QgsProject
from qgis.core import QgsProcessingFeedback
from qgis.core import QgsVectorLayer
from qgis.analysis import QgsNativeAlgorithms
import processing
from processing.core.Processing import Processing
path_qgis_installation = "C:/OSGeo4W64/apps/qgis"
QgsApplication.setPrefixPath(path_qgis_installation, True)
qgs = QgsApplication([], False)
qgs.initQgis()
Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
input_file = QgsVectorLayer('.../file_name.shp')
overlay_file = QgsVectorLayer('.../file_name.shp')
output_fil = '.../file_name.shp'
processing.run(
"native:clip",
{
'INPUT':input_file,
'OVERLAY':overlay_file,
'OUTPUT':output_fil
}
)
qgs.exitQgis()
My problem is that when I run the command (only the processing.run()) in the python console in qgis or in the osgeo shell, everything works.
When I however run it with my python console (bat script), I only get the following (corrupted) files written to disc: .dbf, .shp, .shp. Missing are .prj and .shx for a complete shapefile.
My suspition is that is has something to do with the paths. At one point I executed C:/OSGeo4W64/bin/o4w_env.bat from a location outside of C:/OSGeo464) which then even procued the same problem whilst running on the osgeo shell.
Any suggestion what I am missing to load?