5

I want to do what this person has asked here. I am using QGIS 3.16

I have copied what was suggested and what seemed to work for the OP, however I am not getting any information displayed. The data is a CSV file with Ontario COVID data as well as lat and long info. Excel reads no problem and putting that URL into a web browser will download the CSV file. Ideally I would like to read it directly as it changes daily.

Also, is there a way to debug this in QGIS? I would expect to get some kind of error but it just loads the feature name based on filename with no data. It does append the layer name from the VRT so it must be reading something.

Here is my VRT file:

<OGRVRTDataSource>
<OGRVRTLayer name="COVID Cases">
    <SrcDataSource relativeToVRT="0">"/vsicurl/https://data.ontario.ca/dataset/f4112442-bdc8-45d2-be3c-12efae72fb27/resource/455fd63b-603d-4608-8216-7d8647f43350/download/conposcovidloc.csv"</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="Reporting_PHU_Longitude" y="Reporting_PHU_Latitude"/>
</OGRVRTLayer></OGRVRTDataSource>
0

2 Answers 2

7

The documentation says "SrcLayer is optional". But without it I couldn't add the CSV file as vector layer to QGIS.

I've added <SrcLayer>conposcovidloc</SrcLayer> and changed vsicurl to vsicurl_streaming, then it worked.

<OGRVRTDataSource>
    <OGRVRTLayer name="COVID Cases">
        <SrcDataSource relativeToVRT="0">/vsicurl_streaming/https://data.ontario.ca/dataset/f4112442-bdc8-45d2-be3c-12efae72fb27/resource/455fd63b-603d-4608-8216-7d8647f43350/download/conposcovidloc.csv</SrcDataSource>
        <SrcLayer>conposcovidloc</SrcLayer>
        <GeometryType>wkbPoint</GeometryType>
        <LayerSRS>WGS84</LayerSRS>
        <GeometryField encoding="PointFromColumns" x="Reporting_PHU_Longitude" y="Reporting_PHU_Latitude"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

enter image description here

3

At least I managed to read data with ogrinfo with a little modified VRT file.

<OGRVRTDataSource>
<OGRVRTLayer name="conposcovidloc">
    <SrcDataSource relativeToVRT="0">/vsicurl_streaming/https://data.ontario.ca/dataset/f4112442-bdc8-45d2-be3c-12efae72fb27/resource/455fd63b-603d-4608-8216-7d8647f43350/download/conposcovidloc.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="Reporting_PHU_Longitude" y="Reporting_PHU_Latitude"/>
</OGRVRTLayer></OGRVRTDataSource>

Test with

ogrinfo test.vrt -al
...
OGRFeature(conposcovidloc):1
  Row_ID (String) = 1
  Accurate_Episode_Date (String) = 2020-01-22
  Case_Reported_Date (String) = 2020-01-23
  Test_Reported_Date (String) =
  Specimen_Date (String) = 2020-01-25
  Age_Group (String) = 50s
  Client_Gender (String) = FEMALE
  Case_AcquisitionInfo (String) = TRAVEL
  Outcome1 (String) = Resolved
  Outbreak_Related (String) =
  Reporting_PHU_ID (String) = 3895
  Reporting_PHU (String) = Toronto Public Health
  Reporting_PHU_Address (String) = 277 Victoria Street, 5th Floor
  Reporting_PHU_City (String) = Toronto
  Reporting_PHU_Postal_Code (String) = M5B 1W2
  Reporting_PHU_Website (String) = www.toronto.ca/community-people/health-wellness-care/
  Reporting_PHU_Latitude (String) = 43.65659125
  Reporting_PHU_Longitude (String) = -79.37935801
  POINT (-79.37935801 43.65659125)
2
  • 1
    Ha! This works, thanks much. So it seems the Layer name needs to be the same as the filename, no quotes around data source (which was true in original answer so I guess I screwed up) and the addition of the vsicurl_streaming. Thanks again! Jan 4, 2021 at 1:05
  • Done. I'm only a brain surgeon with a minor in rocket science so I'm not qualified to operate this page correctly. Jan 4, 2021 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.