<div dir="ltr">Hi all,<div><br></div><div>I'm trying to get the file path for an input layer (which is a csv) in a script in QGIS 3. I can see from the algorithm history that it is there in the parameters (see below). However, it seems that when I use `parameterAsFile`, it always returns an empty string. Is this a bug, or am I using it incorrectly?</div><div><br></div><div>What I am looking for is a way to programatically access  "<span style="white-space:pre-wrap;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">C:/GIS/Projects/LizeSuitableHabitatModel/dummySpecies.txt".</span></div><div><span style="white-space:pre-wrap;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div>Thanks,</div><div>Rudi</div><div><br></div><div><b>Algorithm history:</b></div><div>
<p style="margin:0px;white-space:pre-wrap">processing.run("script:suitablehabitatmodel", {'SPECIES_LIST':'file:///C:/GIS/Projects/LizeSuitableHabitatModel/dummySpecies.txt?type=csv&geomType=none&subsetIndex=no&watchFile=no','SPECIES_POINTS':'file:///C:/GIS/Projects/LizeSuitableHabitatModel/dummyPoints.txt?type=csv&xField=DDE&yField=DDS&crs=EPSG:4326&spatialIndex=yes&subsetIndex=no&watchFile=no','MODEL_CRS':'USER:100000','SPECIES_REPROJECT':'C:/Users/rudi_000/AppData/Local/Temp/processing_41d6b6ec7dd342f1bfd813b4b1c79dba/e89a5f992eb94e2291281d57f796e1b0/SPECIES_REPROJECT.shp'})</p><br></div><div><br></div><div><b>Summarised script:</b></div><div><div>def initAlgorithm(self, config=None):</div><div><br></div><div>        self.addParameter(</div><div>            QgsProcessingParameterFeatureSource(</div><div>                self.SPECIES_POINTS,</div><div>                <a href="http://self.tr">self.tr</a>('Species points'),</div><div>                [QgsProcessing.TypeVectorPoint]</div><div>            )</div><div>        )</div><div>        </div><div>    def processAlgorithm(self, parameters, context, feedback):</div><div>       </div><div>        speciesPointsFile = self.parameterAsFile(parameters, self.SPECIES_POINTS, context)  # always returns an empty string</div><div>        genspec = '1031-125'    # this would be set in a loop</div><div><br></div><div>        # trying to apply a filter to the input file by changing the subset parameter</div><div>        uri = f"file:///{speciesPointsFile}?type=csv&xField=DDE&yField=DDS&crs=EPSG:4326&spatialIndex=yes&subsetIndex=no&watchFile=no&subset=%22Genspec%22%20%3D%20\'{genspec}\'"</div><div><br></div><div>        filteredLayer = 

<span style="background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">QgsVectorLayer(uri, 'FILTERED_POINTS', 'delimitedtext')</span>

</div><div>        </div><div>        pointsReprojected = processing.run("native:reprojectlayer", {</div><div>            'INPUT': filteredLayer,</div><div>            'TARGET_CRS': modelCrs.authid(),</div><div>            'OUTPUT' : speciesReprojectOutput</div><div>        }, context=context, feedback=feedback)['OUTPUT']</div></div><div><br></div><div><br></div></div>