[GIS] Pulling CSV file directly from website into QGIS

csvdatabaseqgis

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.

Best Answer

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.

<OGRVRTDataSource>
<OGRVRTLayer name="test">
    <SrcDataSource relativeToVRT="1">test.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>
</OGRVRTLayer></OGRVRTDataSource>
Related Question