Skip to main content
100%

VRT recipe for CSV

✓ Published0🌍 Public
TThomasG77
Last edited Sep 28, 2021
Created on Sep 28, 2021

This example demonstrates how to convert a CSV file containing building bounding box coordinates into a polygon vector layer using a VRT (Virtual Dataset) recipe. The visualization shows a map of building footprints as rectangles derived from the xmin, xmax, ymin, and ymax columns in the CSV. It works by using an OGRVRTDataSource with SQLite dialect in the `demo-sql-csv.vrt` file, where the `ST_PolygonFromText` function constructs spatial geometries from the coordinate data. The technique is presented as a lightweight alternative to processing GeoJSON files, and can be viewed in QGIS or inspected via GDAL command-line tools like `ogrinfo`.

AI-generated description

VRT recipe for CSV

Goal

Show how to display from a VRT file, the bounding box using a CSV as an input. A reaction as a dynamic alternative to https://twitter.com/spatialthoughts/status/1442905558521053184

PS: No approach is better. It depends of requirements.

How to test

You can open in QGIS the file demo-sql-csv.vrt as a vector layer to see CSV layer with a polygon geometry created from xmin, xmax, ymin and ymax

You can also do with GDAL command line

ogrinfo -so -al demo-sql-csv.vrt

Comparison is possible with original buildings source building_before_bounding_box.geojson (CSV was created only for demo purpose)

Feel free to inspect the demo-sql-csv.vrt file content

Similar vizzes