0

I am trying to transform a csv file into a tiff-file (raster). As a first step I am creating a VRT-file. My csv has the following row structure:

E_KOORD,N_KOORD,Z1,Z2,Z3

How do I correctly specify my VRT-file. It looks like I need to parse an array of strings to the 'z'. My python code runs as follows:

import gdal 
import os
fn="/path/to/test.csv" 
vrt_fn="/path/to/test.vrt"
out_tiff="/path/to/test.tiff"
with open(vrt_fn, 'w') as fn_vrt:
    fn_vrt.write('<OGRVRTDataSource>\n')
    fn_vrt.write('\t<OGRVRTLayer name="%s">\n' % "lyr_name")
    fn_vrt.write('\t\t<SrcDataSource>%s</SrcDataSource>\n' % fn)
    fn_vrt.write('\t\t<GeometryType>wkbPoint</GeometryType>\n')
    fn_vrt.write('\t\t<GeometryField encoding="PointFromColumns" x="E_KOORD" y="N_KOORD" z="%s"/>\n' "Z1,Z2,Z3")
fn_vrt.write('\t</OGRVRTLayer>\n')
fn_vrt.write('</OGRVRTDataSource>\n')
gdal.Grid(out_tiff,vrt_fn)

How do I parse in all the columns Z1,Z2 and Z3 into one output file? What is the difference between the 'z' and the 'm' in the line where the 'GeometryField' is specified?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.