manaakiwhenua / pycrown

PyCrown - Fast raster-based individual tree segmentation for LiDAR data
https://datastore.landcareresearch.co.nz/dataset/pycrown
GNU General Public License v3.0
173 stars 65 forks source link

Failed running example - las py "not 'FakeMmap'" #2

Closed sweco-sekrsv closed 4 years ago

sweco-sekrsv commented 4 years ago

Hi!

I tried running the example.py using miniconda (following the instructions) on Windows 10. Python 3.6.9 laspy 1.6.0 LAStools.zip (http://lastools.github.io/download/LAStools.zip downloaded at 2019-12-17)

I get an error:

(pycrown-env) C:\Users\SEKRSV\pycrown\example>python example.py
Traceback (most recent call last):
  File "example.py", line 22, in <module>
    PC = PyCrown(F_CHM, F_DTM, F_DSM, F_LAS, outpath='result')
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\pycrown-0.2-py3.6-win-amd64.egg\pycrown\pycrown.py", line 155, in __init__
    self._load_lidar_points_cloud(las_file)
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\pycrown-0.2-py3.6-win-amd64.egg\pycrown\pycrown.py", line 189, in _load_lidar_points_cloud
    las = laspy.file.File(str(fname), mode='r')
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\laspy\file.py", line 64, in __init__
    self.open()
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\laspy\file.py", line 75, in open
    self._reader = base.Reader(self.filename, mode=self._mode)
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\laspy\base.py", line 273, in __init__
    self.setup_read_write(vlrs,evlrs, read_only=True)
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\laspy\base.py", line 321, in setup_read_write
    self.data_provider.point_map()
  File "C:\Users\SEKRSV\AppData\Local\Continuum\miniconda3\envs\pycrown-env\lib\site-packages\laspy\base.py", line 163, in point_map
    offset=self.manager.header.data_offset)
TypeError: a bytes-like object is required, not 'FakeMmap'

Any ideas how to fix it?

sweco-sekrsv commented 4 years ago

This has something todo with laz-files. Resaving the POINTS.laz to POINTS.las works. Maybe I need to install an older version of laszip.exe?

mavavilj commented 4 years ago

I have the same problem. Would be nice to have some official solution.

This has something todo with laz-files. Resaving the POINTS.laz to POINTS.las works. Maybe I need to install an older version of laszip.exe?

What do you mean by "resaving"? Simply changing the file ending? Or converting it to an actual las ( how?)?

MisterB92 commented 4 years ago

I had the same problem. Indeed saving the files as .las seemed to fix it. In the terminal use:

laszip (yourfile.laz)

it will create a .las file from your .laz file

zjans commented 4 years ago

There seems to be an incompatibility between laszip/laspy and numpy in recent versions. The combination numpy==1.16.4 and laspy==1.5.1 works for me. I suggest either not using .laz files for the time being or downgrading to the appropiate package versions. Please also refer to this github issue: https://github.com/laspy/laspy/issues/112

I replaced the example point cloud with a .las-file for now. The issue should be fixed in this commit: https://github.com/manaakiwhenua/pycrown/commit/66b09817aed12f846adbf16702043f1fcff8afde Please let me know if you still have problems, cheers