On Jun 3, 2009, at 12:31 PM, Wes Toews wrote:
hi, I'm attempting to write the following python code to change the projection information stored in a las 1.1 file in the manner of a demo python script on the liblas site. setup is python2.5, liblas 1.0, using the PyPI python bindings. I'm also not a C programmer.
Hmm... I have not updated the examples since releasing the libLAS 1.2 release. libLAS 1.2 changed things quite significantly in the area of spatial reference systems.
The basic problem is you cannot change the values of header items in- place when doing so would change the size of the header. You must create a new file if this has to happen. Because the coordinate system is stored in variable length records, changing them does indeed change the size of the header and therefore requires that you rewrite the file... (note that the code below is for using the 1.2 version of libLAS)
from liblas import file, srs, header f = file.File('srs.las') # this makes a copy of the header, it is not a reference h = f.headerproj4 = '+proj=lcc +lat_1=47.33333333333334 +lat_2=45.83333333333334 +lat_0=45.33333333333334 +lon_0=-120.5 +x_0=500000.0001016001 +y_0=0 +ellps=GRS80 +datum=NAD83 +to_meter=0.3048006096012192 +no_def's = srs.SRS() s.proj4= proj4 h.srs = s new_file = file.File('newfile.las',mode='w', header=h) for p in f: new_file.write(p) f.close() new_file.close()
Feel free to register for Trac and update the example(s) with code that you get working with :)
this returns LASException: LASError in "LASWriter_Create": PROJ.4 string is invalid or unsupported
This error is related to the issue, and it likely means that proj4 cannot find its data files to look up values. Which libLAS Python binaries are you using? The ones from PyPI, or the ones from OSGeo4W? If you are using the ones from PyPI, I don't think they include the proj4 data files. A quick way to get those would be to install OSGeo4W and then set an environment variable PROJ_LIB to point at c:\osgeo4w\share\proj
Hope this helps, Howard _______________________________________________ Liblas-devel mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/liblas-devel
