2

QGIS 3.24

I want to load a CSV file as a Vector Layer from my Server. The CSV file is regularly updated with new coordinates from a GPS tracker.

My code:

uri = "/vsicurl/http://mydomain.at/iot/gps/cow1.csv?delimiter={}&crs=epsg:4326&xField={}&yField={}".format(";", "longitude", "latitude")
csv_file = QgsVectorLayer(uri, 'cow1', 'delimitedtext')

#Check if layer is valid
if not csv_file.isValid():
    print ("Layer not loaded")
 

#QgsProject.instance().reloadAllLayers()
    
QgsProject.instance().addMapLayer(csv_file)

If I use a local path with "file:///" it works.

uri = "file:///home/data/iot/gps/cow1.csv?delimiter={}&crs=epsg:4326&xField={}&yField={}".format(";", "longitude", "latitude")

But how it works with an URL?

I wrote the script with the buid-in editor. It is executed within the python console.

I get no error, when running. A new layer shows up in the layer menu with the attention symbol and mouseover text "Layer data source could not be found"


what happens if you take off the vsicurl ?

uri = "http://my-domain.at/iot/gps/cow1.csv?delimiter={}&crs=epsg:4326&xField={}&yField={}".format(";", "longitude", "latitude")

Nothing changes. The same problem: "Layer data source could not be found"

3
  • Please edit your question to specify how you are running that code and what happens when you do, including any error messages as text, not screenshots.
    – user2856
    May 15 at 5:21
  • what happens if you take off the vsicurl ?
    – Ian Turton
    May 15 at 11:24
  • Nothing changes. The same problem: "Layer data source could not be found"
    – rkhpd
    May 16 at 11:00

0

Your Answer

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

Browse other questions tagged or ask your own question.