I want to be able to automatically update my csv files in a QGIS project. My organization has an online database that can easily export csv files.

These csv files are constantly updated with new information. I want to be able to link my QGIS project layers directly to the updated csv files so I do not have to constantly be uploading and rejoining layers to have current maps.

Is there an easy way to link the csv file? I am fairly new to QGIS.

  • Welcome to GIS Stack Exchange. This is a good question - does the interchange file format need to be CSV, or would you be happy with any online file format? Can you tell us more about your organization's online database? – Stephen Lead Aug 1 '14 at 4:05
  • Thanks for your comment/Q. My organization's online database is has csv files a user can export for the most up to date info. However, there is a table embedded on the website itself that this csv is drawn from. So to answer your question it could be any format as long as I can directly pull the most recent information into my QGIS project as I continually work on making maps. Does this help? – Weevils Aug 1 '14 at 4:42

You could use an OGR Virtual Format.

This link has a section called "Reading CSV containing spatial information" which shows how to create a VRT file that reads a CSV file with a lat/lon column. This example is a basic template but could be manipulated to suit your case.

Basically you copy the code below into a text file and save it with a file extension of ".vrt". You can then load this into QGIS and theoretically each time you load the VRT file you should see the latest version of the CSV contents. I assume you could change the datasource to be a http end point, I haven't tried that yet. But consuming local csv files this way works.

<OGRVRTLayer name="test">
    <SrcDataSource relativeToVRT="1">test.csv</SrcDataSource>
    <GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
  • 5
    Good start, but you should add the very important bit (as it's the main point of the question)... how to access the CSV over http/s! Change relativeToVRT="1" to relativeToVRT="0" and change the path to use the GDAL /vsi* virtual filesystem, in this case /vsicurl. Something like: /vsicurl/http://example.com/filename.csv – user2856 Aug 1 '14 at 6:22
  • Thanks for this advice, it makes sense. I have a very basic question that doesn't seemed to be answered in any of my searches. How do I upload the VRT to QGIS? I know this is probably rudimentary, but I'm new here. Thanks! – Weevils Aug 1 '14 at 8:10
  • 1
    To add the VRT to your QGIS project, you load it like any other vector layer. Using the "Add Vector Layer" button navigate to where the VRT file is stored and add it to your project. Alternatively you can just drag and drop it right in there. – Andrew Jeffrey Aug 1 '14 at 10:13
  • That seems to do the trick! Thanks for your help on this! – Weevils Aug 5 '14 at 4:16

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.