Open mdsumner opened 10 months ago
bit more of an example with streaming reprojection
'<OGRVRTDataSource>
<OGRVRTWarpedLayer>
<OGRVRTLayer name="source">
<SrcDataSource>source.shp</SrcDataSource>
</OGRVRTLayer>
<TargetSRS>EPSG:4326</TargetSRS>
</OGRVRTWarpedLayer>
</OGRVRTDataSource>'
library(xml2)
target_crs <- NULL
target_crs <- "+proj=laea"
schema <- read_xml("https://raw.githubusercontent.com/OSGeo/gdal/master/data/ogrvrt.xsd")
xml <- xml_new_root("OGRVRTDataSource")
if (!is.null(target_crs)) {
xml_add_child(xml, "OGRVRTWarpedLayer")
}
xml_add_child(tail(xml_children(xml), 1), "OGRVRTLayer", name = "CGAZ_query")
xml_add_child(xml_children(xml_children(xml)), "SrcDataSource", sds::CGAZ())
xml_add_child(xml_children(xml_children(xml)), "SrcSQL", "SELECT * FROM geoBoundariesCGAZ_ADM0", dialect = "SQLITE")
xml_add_child(tail(xml_children(xml), 1), "TargetSRS", target_crs)
xml_validate(xml, schema)
write_xml(xml, "/tmp/file.vrt", options = "no_declaration")
#
# #dsn <- "<OGRVRTDataSource><OGRVRTWarpedLayer><OGRVRTLayer name=\"CGAZ_query\"/><TargetSRS>+proj=laea</TargetSRS><SrcSQL>SELECT * FROM geoBoundariesCGAZ_ADM0 LIMIT 1</SrcSQL></OGRVRTWarpedLayer></OGRVRTDataSource>\n<SrcDataSource>/vsizip//vsicurl/https://github.com/wmgeolab/geoBoundaries/raw/main/releaseData/CGAZ/geoBoundariesCGAZ_ADM0.zip</SrcDataSource"
dsn <- trimws(readr::read_file("/tmp/file.vrt"))
plot(wk::wkb( vapour::vapour_read_geometry("/tmp/file.vrt")))
#
having trouble with the ST_funs for SQLITE dialect ...