[Liblas-devel] Writing VLR?

Howard Butler hobu.inc at gmail.com
Sun Nov 2 21:08:20 EST 2008


Jason,

The docs are not very forthcoming about this, but the VLRs that you  
are editing are maintained by libLAS and over-/re-written when the  
file is written (meaning any changes you're doing, like tweaking the  
description, are dropped).  Any of the VLRs that have record IDs of  
34735, 34736, or 34737 are maintained by libLAS separately.  My  
thinking here was it would be more beneficial to the users to be able  
to just write proj4 and have libLAS maintain the conversion of that to  
the necessary VLRs.  I could probably be persuaded that this isn't  
exactly the best idea in the world, but it seemed like the lesser of  
multiple evils at the time.

In summary, if you want to write VLRs, as long as the record IDs  
aren't any of the spatial reference ones, they should stick.

To write data into a VLR from python, you must use a ctypes c_ubyte  
directly.  See the VLR test for an example:

http://liblas.org/browser/trunk/python/tests/VLR.txt

Howard


On Nov 2, 2008, at 1:27 PM, Jason Woolard wrote:

> hi,
>
> The "test" docs on the Trac page have been very helpful but does  
> anyone have an example of writing a VLR. It seems that I can create  
> a VLR and update it (see below) but I can't write it to the file. I  
> tried writing a point to the file which works for updating the proj4  
> header tag but I'm guessing the VLR requires something different.
>
> >>> import liblas
> >>> from liblas import file
> >>> from liblas import header
> >>> from liblas import vlr
> >>> input = liblas.file.File('C:\\liblas_test\ 
> \debug_new.las',mode='r')
> >>> h = input.header
> >>> h.records_count
> 2L
> >>> h.proj4
> '+proj=tmerc +lat_0=0.000000000 +lon_0=-81.000000000 +k=0.999600  
> +x_0=500000.000 +y_0=0.000 +ellps=WGS84 +units=m '
> >>> v = h.GetVLR(0)
> >>> v.recordid
> 34735
> >>> v.userid
> 'LASF_Projection'
> >>> v.description
> ''
> >>> v.description = 'UTM zone 17 meters WGS84'
> >>> v.description
> 'UTM zone 17 meters WGS84'
> >>> output = liblas.file.File('C:\\liblas_test\ 
> \debug_out.las',mode='w',header=h)
> >>> output.write(input.read(0))
> >>> output.close()
> _______________________________________________
> Liblas-devel mailing list
> Liblas-devel at mail.hobu.net
> http://mail.hobu.net/mailman/listinfo/liblas-devel




More information about the Liblas-devel mailing list