Comments (1)
The SubFieldView class was introduced to fix an inconsistency between 'subfields' (fields that are bit fields and are stored on less than a byte, such as return_number) and other regular fields (eg: gps_time, user_data, point_source_id)
In pylas < 0.5 when accessing a sub field las.return_number
a copy would be returned, meaning that modifications whould not
propagate.
import pylas
las = pylas.read("pylastests/simple.las")
import numpy as np
print(las.return_number)
# array([1, 1, 1, ..., 1, 1, 1], dtype=uint8)
ascending_order = np.argsort(las.return_number)[::-1]
print(las.return_number[ascending_order])
# array([4, 4, 4, ..., 1, 1, 1], dtype=uint8)
las.return_number[:] = las.return_number[ascending_order]
print(las.return_number)
# array([1, 1, 1, ..., 1, 1, 1], dtype=uint8) # bif oof
# To actually update you have to do
rn = las.return_number[ascending_order]
las.return_number = rn
print(las.return_number)
# array([4, 4, 4, ..., 1, 1, 1], dtype=uint8)
Whereas with pylas >= 0.5 the same script would have a more consistent behaviour.
The SubFieldView tries to behave has much as possible as a np.ndarray, however there may be things that cannot be possible to
immitate.
As for errors you mentionned:
>>> np.concatenate([cloud.return_number, cloud.return_number])
...
ValueError: zero-dimensional arrays cannot be concatenated
^ Should be fixable
>>> cloud.return_number[0] + 1
...
TypeError: unsupported operand type(s) for +: 'SubFieldView' and 'int'
^ should be fixable
>>> ordered = np.argsort(cloud.gps_time)
>>> cloud.return_number[:] = cloud.return_number[ordered]
...
TypeError: unsupported operand type(s) for <<: 'SubFieldView' and 'int'
^ Is already fixed on master
>>> field = np.zeros(len(cloud.points), dtype=np.uint8)
>>> field[:] = cloud.return_number[:]
...
TypeError: __array__() takes 1 positional argument but 2 were given
^ I don't think it is fixable.
however you can copy the SubFieldView into a proper numpy array
field = np.array(cloud.return_number)
print(field)
# [4 4 4 ... 1 1 1]
# if field is modified:
las.return_number[:] = field[:]
from pylas.
Related Issues (20)
- Writing empty .LAZ makes python crash HOT 1
- Piping LAS with extra bytes through laszip.exe to compress it produces bad files HOT 1
- Buffer smaller than requested size for some LAS files HOT 6
- Saving file after update_header HOT 3
- Uppercase extensions HOT 1
- More open modes HOT 1
- Improve/Fix Weird behaviour of sub fields
- EVLR support is clunky
- Improve EVLR handling
- Rework tests
- Handle Scaled Extra Bytes
- Helper to write SRS as WKT in VLR format HOT 2
- "lasrs" compression not working with current release in PyPi 0.4.3 HOT 2
- Seekable reader HOT 2
- Truncating return numbers HOT 6
- Write return value HOT 2
- remove dimension HOT 1
- Error when decompressing laz file HOT 2
- Converting Lidar .las / .laz to .tif
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylas.