VRT recipe for CSV
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 descriptionVRT 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
- Download the file with https://gist.github.com/ThomasG77/fd07ef0a2d384e024bd06675ca0615cc/archive/master.zip
- Unzip it
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