laspy / laspy Goto Github PK
View Code? Open in Web Editor NEWLaspy is a pythonic interface for reading/modifying/creating .LAS LIDAR files matching specification 1.0-1.4.
Home Page: https://laspy.readthedocs.io/en/latest/
License: Other
Laspy is a pythonic interface for reading/modifying/creating .LAS LIDAR files matching specification 1.0-1.4.
Home Page: https://laspy.readthedocs.io/en/latest/
License: Other
I'm getting a no treated exception when trying to access header.project of a LAZ (laszip compressed) file:
f=laspy.file.File(r"G:\TRANSECTS\VALIDATING\NP_T-0001.laz")
print f.header.project_id
Traceback (most recent call last):
File "C:\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3066, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
print f.header.project_id
File "C:\Anaconda\lib\site-packages\laspy\header.py", line 707, in get_projectid
return(uuid.UUID(bytes =p1+p2+p3+p4))
TypeError: unsupported operand type(s) for +: 'memoryview' and 'memoryview'
It works fine in a LAS file.
Hi,
I've tried to install the new laspy 1.4.0 in a Python 3.4 environment. It does not work. With laspy 1.2.5 it used to work. I know that laspy focuses on Python 2.7 but since i need to work with Pythonb 3 I would like to know if is there is a way to install it?
Here is the error message for pip install laspy for Python 3.4.3:
(rs)mac:~ will$ pip install laspy
Collecting laspy
Using cached laspy-1.4.0.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 20, in
File "/private/var/folders/gz/t3r4_mbs2g11gd54w4ksj7xc0020_6/T/pip-build-72bnfzq8/laspy/setup.py", line 4, in
import laspy
File "/private/var/folders/gz/t3r4_mbs2g11gd54w4ksj7xc0020_6/T/pip-build-72bnfzq8/laspy/laspy/init.py", line 3, in
import base
ImportError: No module named 'base'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/gz/t3r4_mbs2g11gd54w4ksj7xc0020_6/T/pip-build-72bnfzq8/laspy
This is particularly important for waveform data, which is too big to be parsed under the current framework.
The documentation could be clearer about this.
Hi,
I was just wondering if there was a way to read only the header from the .laz/.las file. I have to process a bunch of .laz files and just needed to know their bounding boxes.
From what I am seeing the whole data is read in once File(path)
is called (including points mapped to numpy array). I tried to look at the code for HeaderManager
and calling it directly but cant seem to get it to work.
Thanks!
It's been almost a year since the last release. There hasn't been a lot of changes since then, but the project has seen some activity.
Personally I am holding back on using Laspy in prodcution code since the latest release doesn't write files fast enough. That has been improved significantly since the last release. A new release with the latest changes would satisfy my needs for using laspy in production.
Apparently, the current laspy in the master is not compatible with Python 3. It would be helpful if the documentation or readme mentions Python 2 requirement.
Is this still up-to-date : https://github.com/grantbrown/laspy/blob/master/laspy/file.py#L42-L45 ?
(I do not think so, but I am not sure...)
Currently uses keyboard based navigation.
The camera doesn't move with the given keys. I'm using laspy on linux, with pyopengl 3.1.
Hi,
I am using laspy1.2.5 along with numpy 1.9.2 and pyproj 1.9.4 and I found a strange behavior.
When I run my LAS converter[1] under Linux (Linux Mint / 17.2 / 64bit) it works well. When I try the code on Windows 7 (with same Python components and Python 2.7.10) I got this exception:
Traceback (most recent call last):
File "C:/development/wgslas2eovlas/wgslas2eovlas.py", line 235, in <module>
main()
File "C:/development/wgslas2eovlas/wgslas2eovlas.py", line 229, in main
ConvertLas(d)
File "C:/development/wgslas2eovlas/wgslas2eovlas.py", line 106, in ConvertLas
lasFiles.Open()
File "C:\development\wgslas2eovlas\lib\LasPyConverter.py", line 20, in Open
self.__SourceOpenedFile = laspy.file.File(self.__SourceFileName, mode='r')
File "C:\Python27\lib\site-packages\laspy-1.2.5-py2.7.egg\laspy\file.py", line 62, in __init__
self.open()
File "C:\Python27\lib\site-packages\laspy-1.2.5-py2.7.egg\laspy\file.py", line 73, in open
self._reader = base.Reader(self.filename,mode= self._mode)
File "C:\Python27\lib\site-packages\laspy-1.2.5-py2.7.egg\laspy\base.py", line 153, in __init__
self.setup_read_write(vlrs, evlrs)
File "C:\Python27\lib\site-packages\laspy-1.2.5-py2.7.egg\laspy\base.py", line 164, in setup_read_write
self.data_provider.map()
File "C:\Python27\lib\site-packages\laspy-1.2.5-py2.7.egg\laspy\base.py", line 95, in map
raise LaspyException("Error mapping file.")
laspy.util.LaspyException: Error mapping file.
[1] https://github.com/KAMI911/wgslas2eovlas/tree/07c1420165c7ffebbafe642dfe870c746fa31f4a
Do you have idea what causes the error and how to fix it? The LAS files that I would like to open around 700MB.
Thank you in advance!
KAMI
This is a great library. Thanks to the author for your hard work putting this together.
I've been toying around with it for applications in Ecology. One of the problems I've been working on requires either sequential or parallel processing of hundreds of las files (I rasterize the point clouds into a digital elevation model and digital surface model).
I have run into an issue with iterating over a list of files [i.e., glob.glob('*.las')
]. There are some code blocks below, but what follows is a general description of what happens.
I run the top command and watch system resources in a separate terminal from python. Memory allocated to Python continually increases as I sequentially iterate over the filenames, open the files in read mode, use data from the files, close the file, and repeat. I first noticed the problem in a script, but the same thing happens when running commands from within ipython. When I use dir() to list the objects in the main namespace in Python after already closing the las file there are still references to the data objects I used from the file. Trying to use these data objects at this point results in a segmentation fault.
I'm not sure what the best way is to make a reproducible result, because that would require transferring the las files somewhere. I expect the same thing will happen with any collection of las files though.
I am using laspy 1.2.5 / 64bit Anaconda on Mac OS X. Some toy code follows,
import glob, numpy as np, laspy
#assumes you are in a directory with a collection of las files
files = glob.glob("*.las")
for i, f in enumerate(files):
#print the number of the file in the iteration and the filename
print i, f
# open file
las = laspy.file.File(f, mode="r")
#use point data
points = las.points
#do something with point data -- trivial example here is printing points
print points
#close las file
las.close()
Something similar, but perhaps more insightful about what is going on follows. Warning... this crashes on my system.
import glob, numpy as np, laspy
#assumes you are in a directory with a collection of las files
files = glob.glob("*.las")
f0 = files[0]
las = las.file.File(f0, mode="r")
points = las.points
las.close()
#list objects in main namespace
dir()
#points is still present in the namespace
#calling points now will crash python with a segfault
points
When I run:
$ lasviewer file.las
Errors comes:
Something went wrong:
No module named glviewer
I have run the below command to install laspy
:
conda install laspy
Got the following error:
Fetching package metadata ..........
PackageNotFoundError: Package missing in current osx-64 channels:
- laspy
ie, code example for
import laspy
Hi,
I'm using laspy 1.4.2 installed via conda on Ubuntu 14.04 and I'm getting following error when trying to open LAS file (see link):
inFile = laspy.file.File('960.las', mode = "r")
Traceback (most recent call last):
File "/home/friend/PycharmProjects/fm/var_calc.py", line 23, in
inFile = laspy.file.File('960.las', mode = "r")
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/file.py", line 63, in init
self.open()
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/file.py", line 74, in open
self._reader = base.Reader(self.filename, mode=self._mode)
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/base.py", line 250, in init
self.setup_read_write(vlrs,evlrs, read_only=True)
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/base.py", line 307, in setup_read_write
self.data_provider.remap(point_map = True)
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/base.py", line 199, in remap
self.map()
File "/home/friend/miniconda2/lib/python2.7/site-packages/laspy/base.py", line 191, in map
raise laspy.util.LaspyException("Error mapping file: " + str(e))
laspy.util.LaspyException: Error mapping file: [Errno 22] Invalid argument
I would appreciate any help in solving this issue.
Thanks, Yuri
Large (>1-3 GB) las files fail to open with 32 bit python.
Current workaround is to use 64 bit python, along with the appropriate 64 bit numpy.
I'm reading a LAS file with some EXTRA BYTES and I noticed that accessing them with inFile.<extrabytesvaluename>
(lower-case) returns the raw value arrays. The LAS Specification 1.4 pages 24-26, describes the format of the EXTRA BYTES VLR, and it mention that they may have associated scales and offsets, controlled by the options
field inside the VLR (see Table 25), and that the type is controlled by the data_type
field (see Table 24).
So, to be coherent with the rest of the package, I think the raw values should be accessed using inFile.<Extrabytesvaluename>
(captioned) and the scaled value with offset applied should be available through inFile.<extrabytesvaluename>
according with the controlling bits set in the option
field (like it is done with inFile.X
and inFile.x
). The correct type can also be deduced from the data_type
fields (chars, ints, floats, up to vectors of size 3), returning the appropriate vector.
Do you plan to implement this idea anytime soon? If someone give me some pointers to where to start I can try to adapt the code to handle the EXTRA BYTES in the way I described here.
It looks like there's a full fork that has Python 3 support
numpy is specified as a dependency in setup.py
as it should. However, the current setup.py
imports laspy first, which requires numpy. So in environments that do not have numpy installed a simple pip install laspy
will fail.
The correct behaviour should be to install numpy automatically if it is not present.
Hi, I'm importing laspy into ipython notebooks. For the longest time I could not get it to recognize file:
1 import laspy
2 filename = r"/Users/Kit/laspy-1.2.5/laspytest/data/simple.las"
----> 3 infile = laspy.file.File(filename, mode="r")
AttributeError: 'module' object has no attribute 'file'
Then, miraculously! it worked just fine for a day or two, but now if fails again -- same error. I have changed nothing in the code nor anything regarding laspy in the terminal, only installed liblas. Laspy still passes all tests in python setup.py test and imports fine both in notebooks and in terminal. file.py is in the laspy folder and looks fine. Any advice?
Right now it's blank, which is stupid.
There seems to be an issue with version and file_signature, which appear as version_major/version_minor and file_sig. Check for other problems as well (there are some formatting problems etc.)
Further development on the las visualizer will take place on silyko's lasviewer repository.
It would be great if it were possible to quickly access big LAS/LAZ files that are too large to fit main memory. For instance to load only a subset or to just view the header data.
I didn't find a way to do this with laspy, so unless I'm missing something this is a feature request.
I can see in the tests that creating a file with a naked header.Header() (as opposed to a HeaderManager) object works, but when I try it in my example I don't get a valid file.
import laspy
from laspy.file import File
import laspy.header as Header
import numpy as np
import argparse
import logging
import random
class random_las_file_generator():
def __init__(self):
self.parse_args()
def parse_args(self):
parser = argparse.ArgumentParser(description="""Accept the path to a .LAS file,
and print a list of point records
with invalid (X,Y,Z) information.""")
parser.add_argument("output", metavar="Output", type = str, nargs=1, help = "File name for output to write")
parser.add_argument("--log", metavar="Log", type = str, nargs=1, help ="Path to log file", default = "")
parser.add_argument("--extent", metavar="Extent", type = float, nargs = 1, help = "Extent in kilometers", default = 1.30)
parser.add_argument("--count", metavar="Count", type = int, nargs = 1, help = "Number of points to generate", default = 20000)
self.args = parser.parse_args()
try:
len(self.args.extent)
self.args.extent = float( self.args.extent[0])
except TypeError:
pass
def do(self):
logging.info("Writing output: " + self.args.output[0])
logging.info("Extent is '%.3f' km " % self.args.extent)
logging.info("Count is '%d' points" % self.args.count)
domain = 2**32-1
minx = random.uniform(0, 100000)
miny = random.uniform(0, 100000)
maxx = minx + 1000*self.args.extent
maxy = miny + 1000*self.args.extent
minz_bounds = -100.0
maxz_bounds = 2500.0
minz = random.uniform(minz_bounds,maxz_bounds)
maxz = random.uniform(minz,maxz_bounds)
logging.debug("minx is '%.5f'" % minx); logging.debug("maxx is '%.5f'" % maxx)
logging.debug("miny is '%.5f'" % miny); logging.debug("maxy is '%.5f'" % maxy)
logging.debug("minz is '%.5f'" % minz); logging.debug("maxz is '%.5f'" % maxz)
delta_x = maxx - minx
delta_y = maxy - miny
delta_z = maxz - minz
scale_x = delta_x/float(domain)
scale_y = delta_y/float(domain)
scale_z = delta_z/float(domain)
logging.debug("scalex: '%.12f'" % scale_x );
logging.debug("scaley: '%.12f'" % scale_y )
logging.debug("scalez: '%.12f'" % scale_z )
offset_x = minx
offset_y = miny
offset_z = minz
delta_x = maxx - minx
delta_y = maxy - miny
delta_z = maxz - minz
domain = 2**32-1
scale_x = delta_x/float(domain)
scale_y = delta_y/float(domain)
scale_z = delta_z/float(domain)
h = Header.Header()
h.x_scale = scale_x
h.y_scale = scale_y
h.z_scale = scale_z
h.x_offset = offset_x
h.y_offset = offset_y
h.z_offset = offset_z
h.version = '1.2'
f = File(self.args.output[0], mode='w', header=h)
f.x = np.random.uniform(minx, maxx, size=self.args.count)
f.y = np.random.uniform(miny, maxy, size=self.args.count)
f.z = np.random.uniform(minz, maxz, size=self.args.count)
f.close()
def main():
randomizer = random_las_file_generator()
log = randomizer.args.log
logging.basicConfig(filename=log,level=logging.DEBUG)
randomizer.do()
if __name__=='__main__':
main()
Try running this like
python simulate.py junk.las
I've confirmed that virtualenv environments work as expected, but need to do some digging wrt conda.
I have hesitated to ask this question, because I don't know if this is the correct forum to ask questions that are mainly usage related. However, I have decided that this question is both an API issue and documentation issue so is relevant to ask here.
A common problem for people working on lidar datasets is rasterizing point clouds. Documenting how to pull out the projection information from each las file version would make it much easier to write code that can rasterize a point cloud.
This is a feature request to document how to easily obtain the metadata needed for using lidar data read by laspy that is required to produce a georeferenced raster using GDAL. The main challenge I have run into is getting the projection from the las file using laspy. I've yet to figure out how to do this with 1.0 las files that I know have projection metadata.
More generally, is there any interest in having a user forum to discuss usage of laspy where both laspy users and developers can ask questions not directly related to development of laspy, but geared at laspy usage? Laspy is a library that sits in a wonderful ecosystem of open source geospatial software that is well supported by Python developers. The laspy documentation does not explain how to use laspy in the broader context of other geospatial libraries -- such as GDAL -- that can be used to rasterize a point cloud.
Hey guys,
Just a heads up, I ran into this issue while trying to install 1.3.0 via pip...
(on windows 8.1, using python 2.7.11 64 bit )
pip install laspy Collecting laspy Using cached laspy-1.3.0.tar.gz Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 20, in File "c:\users\andrew~1.hew\appdata\local\temp\pip-build-tlkoee\laspy\setup.py", line 28, in shutil.copyfile("laspytest/data/simple.laz", "simple.laz") File "c:\python27-64\lib\shutil.py", line 82, in copyfile with open(src, 'rb') as fsrc: IOError: [Errno 2] No such file or directory: 'laspytest/data/simple.laz' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in c:\users\andrew~1.hew\appdata\local\temp\pip-build-tlkoee\laspy
Using version 1.2.5 installs fine...
pip install laspy==1.2.5 Collecting laspy==1.2.5 Using cached laspy-1.2.5.tar.gz Requirement already satisfied (use --upgrade to upgrade): numpy in c:\python27-64\lib\site-packages (from laspy==1.2.5) Installing collected packages: laspy Running setup.py install for laspy Successfully installed laspy-1.2.5
Hi there, are there plans to add compression support to laspy? Per https://github.com/laspy/laspy/blob/master/laspy/header.py#L969 :
Controls compression for this file.
If True, the file is compressed with lasZIP compression and will
be written with lasZIP compression. If False, the file is not
compressed. Not implemented in laspy.
I also tried myfile.header.compressed = True
and myfile.header.set_compressed(True)
, just to give it a shot; both seem to have no effect. Is adding support for this on the table?
laz-perf provides a header-only C++11 implementation of LAZ read/write support. We can write some cython that provides VLR access and read/write support for laspy using this library.
There is pretty minimal documentation of this process.
I have found that header.date returns a datetime value one day in advance of what is actually recorded in the LAS header, regardless of leap year or not.
Thanks for developing this great library. Would be very cool if laspy also could read laz files. Just checked with a quick hack, which seemed to work (partly). The idea is to be able to call with a buffer object instead of a filename, something like:
prc=subprocess.Popen(["laszip","-olas","-stdout","-i","somefile.laz"],stdout=subprocess.PIPE,bufsize=-1)
data,stderr=prc.communicate()
f=FakeMmap(data)
with FakeMmap being something like (just a really, quick and dirty hack):
class FakeMmap(object):
def init(self,data):
self.data=buffer(data)
self.pos=0
def getitem(self,i):
return self.data[i]
def tobuffer(self):
return self.data
def flush(self):
pass
def fileno(self):
return 0
def close(self):
pass
def size(self):
return len(self.data)
def seek(self,bytes,pos):
if pos>0:
self.pos+=bytes
else:
self.pos=bytes
def read(self,bytes):
return self.data[self.pos:self.pos+bytes]
def tell(self):
return self.pos
Changed a few lines here and there in base.py and got it to work (mostly). Not sure if this is the right approach to take, but would enable laz-reading. Perhaps a keyword (is_buffer=True) in file.File ?
Cheers,
Simon
Looking at the __init__
method for the Header
class, it's not used at all. How does one create a header with a different point_format?
Hi,
I am not sure that this is the best place for my question... but I do not know if this is some kind of bug, or if I misunderstood something (or missed something). I am simply trying to open some LAS files...
I am using Python 2.7.10 32-bits on Windows 7.
If they are on the local disk of my computer, then it works perfectly. If the LAS files are on an external (or mapped) folder, then it does not work...
Here is a simple example using the same file twice:
Python code:
from laspy import file
import os
print "Read a local file:"
tile = 'C:/11234421073.las'
tile_exists = os.path.isfile(tile)
print tile_exists
file_ = file.File(tile, mode = 'r')
print type(file_)
print "Done"
print "Read an external file:"
tile = 'F:/11234421073.las'
tile_exists = os.path.isfile(tile)
print tile_exists
file_ = file.File(tile, mode = 'r')
print type(file_)
Output:
Read a local file:
True
<class 'laspy.file.File'>
Done
Read an external file:
True
Traceback (most recent call last):
File "test_las_open.py", line 23, in <module>
file_ = file.File(tile, mode = 'r')
File "C:\travail\tmp\las\lib\site-packages\laspy\file.py", line 62, in __init__
self.open()
File "C:\travail\tmp\las\lib\site-packages\laspy\file.py", line 73, in open
self._reader = base.Reader(self.filename,mode= self._mode)
File "C:\travail\tmp\las\lib\site-packages\laspy\base.py", line 153, in __init__
self.setup_read_write(vlrs, evlrs)
File "C:\travail\tmp\las\lib\site-packages\laspy\base.py", line 163, in setup_read_write
self.data_provider.open("r+b")
File "C:\travail\tmp\las\lib\site-packages\laspy\base.py", line 30, in open
raise LaspyException("Error opening file")
laspy.util.LaspyException: Error opening file
Does anyone have a clue why the external opening does not work ? (I have not got a clue...)
Thanks !
The lasviewer should to default to rgb mode if it's on the format and a reasonable sampling of it is not 0's
Hello everyone,
I'm using laspy from one month, and I would like to know how subsampled a las file and save it ? It's possible ?
Arthur
Hello,
I'd like to be able to read a Laz / Las file that is stored in a buffer using laspy .
However it doesn't seem possible as the interface only accepts filenames.
This would allow to download a file from an external resource (for example an aws s3 bucket), process the file and then upload it back.
This could be useful to avoid downloading the file to disk, reading it, rewriting it and then uploading it.
Is it not possible at all currently ?
Hi,
I am seeing some memory leaks. Have not debugged it fully, but I believe it's due to objects keeping a reference to a base.FileManager object (file.File._reader). E.g. reader.header will hold a reference to reader. When reader is set to None in file.File.close, there will still be unreachable references to reader.
This amounts to some memory, e.g. when reader.point_refs is a really long list.
Problem can be reproduced with something like:
import sys
import gc
import laspy.file as lasf
gc.set_debug(gc.DEBUG_LEAK)
plas = lasf.File(sys.argv[1])
p = plas.points
del p
print gc.collect() # No unreachable objects yet
plas.close()
del plas
print gc.collect() # A lot of unreachable objects
Hello everyone,
I'm trying to open a laz file to read and write on the classification. But when I run this command:
inFile = File("test.laz", mode = "rw")
I have the following message:
File "D:\Program Files (x86)\Python36-64\lib\site-packages\laspy\file.py", line 64, in __init__
self.open()
File "D:\Program Files (x86)\Python36-64\lib\site-packages\laspy\file.py", line 94, in open
self._writer = base.Writer(self.filename,mode = self._mode)
File "D:\Program Files (x86)\Python36-64\lib\site-packages\laspy\base.py", line 268, in __init__
self.setup_read_write(vlrs, evlrs, read_only=False)
File "D:\Program Files (x86)\Python36-64\lib\site-packages\laspy\base.py", line 293, in setup_read_write
self.data_provider.map()
File "D:\Program Files (x86)\Python36-64\lib\site-packages\laspy\base.py", line 209, in map
raise laspy.util.LaspyException("Error mapping file: " + str(e))
laspy.util.LaspyException: Error mapping file: 'bool' object has no attribute 'fileno'
If someone knows why I have this, I'll happy to know the answer!
I work on windows 10 64 bits, Python 3.6.2 and laspy 1.5.0
Thanks,
Arthur
Hi,
Sorry if I'm not posting into the right place.
I need to access values stored in the extrabyte area of my LiDAR points.
I can't find out how to do this with laspy ?
Any idea ?
Thanks a lot,
Alex
I was just trying to write out a bunch of points that do not actually come from selection among those in a LAS file, like the tutorial currently assumes, and I couldn't figure out how to set them. I.e., I have a laspy.file.File
called out
, I've managed to set the header and the data format, but then the .points
is None
and I can't find a way to get the right dtype
. Just setting out.points = my_array
doesn't work because the shapes don't match up.
Shouldn't there be some method that returns the NumPy dtype that will be used to represent points in the selected data format?
The points are in a NumPy array of shape (N, 6)
(XYZRGB), produced by python-pcl.
Hi,
I'm using laspy 1.4.2/numpy 1.11.2 installed via conda on Ubuntu 14.04 that runs on VirtualBox, and I'm getting wrong values when accessing extra_bytes of my LAS file (see link):
inFile = laspy.file.File('960.las', mode = "r")
print inFile.height_above_ground
I'm getting random, negative values instead of actual height values.
Thanks for any advice,
Yuri
one more cross-post... (also on SO and GIS StackExchange)
I'm trying to change the header info for a LAS file using the python 2.7 (64-bit) laspy module (version 1.2.5). I'm attempting to follow the example shown here (in the section "Writing Data + EVLRS"): http://laspy.readthedocs.io/en/latest/tut_part_3.html
However when I update the EVLR info with the new content, I get this error message:
Error text: ValueError: offset must be non-negative and no greater than buffer length (1094) This error shows up on line 151 of laspy/base.py:
self._pmap = np.frombuffer(self._mmap, self.pointfmt,
offset = self.manager.header.data_offset,
count = self.manager.header.point_records_count)
The "buffer length" value of 1094 seems to be the same as the length of the EVLR text record, while the "data_offset" value above is a much higher value of 4151.
import numpy as np
import laspy
import shutil
import datetime
print('Update started: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
# Set input / output filenames
evlrContentFile = "./LAS_DATA/evlrContentFile.txt"
inFileName = './LAS_DATA/infile.las'
outFileName = './LAS_DATA/outfile.las'
# Get EVLR string content
with open(evlrContentFile, "r") as evlrFile:
evlrString=evlrFile.read();
# make a copy
shutil.copy(inFileName,outFileName);
# open the outfile for modification
outFile_v14 = laspy.file.File(outFileName, mode = "rw")
# create a new EVLR header entry
new_evlr = laspy.header.EVLR(user_id = 10, record_id = 2,
VLR_body = evlrString)
# update the outfile EVLR header entries
old_evlrs = outFile_v14.header.evlrs
old_evlrs.append(new_evlr)
outFile_v14.header.evlrs = old_evlrs
outFile_v14.close()
print('Update Completed: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
I want to modify the existing files with the new header info with a minimum of processing, so I want to avoid using laspy to copy the contents of the LAS points to the new output file if possible. Hence why I am using the "rw" modify option instead of "w" to create the output file... Also, so I don't modify my test LAS file destructively...
The contents of the EVLR text file are shown below:
COMPD_CS["NAD83(2011) / UTM zone 10N + NAVD88 height",PROJCS["NAD83(2011) / UTM zone 10N",GEOGCS["NAD83(2011)",DATUM["NAD83_National_Spatial_Reference_System_2011",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","1116"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","6318"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-123],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],AUTHORITY["EPSG","6339"]],VERT_CS["NAVD88 height",VERT_DATUM["North American Vertical Datum 1988",2005,EXTENSION["PROJ4_GRIDS","g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx"],AUTHORITY["EPSG","5103"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Up",UP],AUTHORITY["EPSG","5703"], AUTHORITY["EPSG","6349"]]]
Hi,
I am kind of a fan of laspy since I recently discovered it and tried it with a few LAS files I have.
I now am in trouble because I am forced to use a python installation shipped with a GIS software (ArcGIS Pro), which is version 3.5. The reason is that it contains a module (arcpy) which is only present with this installation.
I am aware that laspy works with Python 2.7, but as suggested in issue #40 I tried to install the fork of GeospatialPython. Nevertheless, I failed to have it working though.
What I did was:
downloaded the zip from the forked repository and unzipped it to a directory (let's call it [DIR])
opened a cmd terminal with admin privileges (I'm on Win10) and cd to the root laspy directory (as explained in the docs)
did "python setup.py build"
I am sure I am using the right interpreter (the 3.5 shipped with ArcGIS Pro). After that, I received:
Traceback (most recent call last):
File "setup.py", line 4, in <module>
import laspy
File "C:\Umberto\lidar\laspy\geospatial_fork\laspy-master\laspy\__init__.py", line 3, in <module>
import base
ImportError: No module named 'base'
Does anyone have any idea on what's going on? Is it because the laspy in the fork I am using is just compatible with python 3.4 and not 3.5? Or am I missing something else? Thanks in advance!
P.S. I would have added a new issue on the GeospatialPython repository, but I couldn't see any way to do that (my understanding of github is kind of basic...).
When we try to open a read-only file (no write permission) with mode="r", it is changed internally to "r+" before trying to open the file on laspy.base.DataProvider.open().
Mode "r+" expects write permission, so the open fails, and laspy stops with the exception raised on laspy/base.py, line 128
Problem found on laspy 1.5.0.
re-implement with shift operators
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.