INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Return a list of parameter objects.
def parameters(self) -> List['Parameter']: """Return a list of parameter objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ Parameter(_lststr, _type_to_spans, span, 'Parameter') for span in self._subspans('Parameter')]
Return a list of parser function objects.
def parser_functions(self) -> List['ParserFunction']: """Return a list of parser function objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ ParserFunction(_lststr, _type_to_spans, span, 'ParserFunction') for span in self._subspans('P...
Return a list of templates as template objects.
def templates(self) -> List['Template']: """Return a list of templates as template objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ Template(_lststr, _type_to_spans, span, 'Template') for span in self._subspans('Template')]
Return a list of wikilink objects.
def wikilinks(self) -> List['WikiLink']: """Return a list of wikilink objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ WikiLink(_lststr, _type_to_spans, span, 'WikiLink') for span in self._subspans('WikiLink')]
Return a list of comment objects.
def comments(self) -> List['Comment']: """Return a list of comment objects.""" _lststr = self._lststr _type_to_spans = self._type_to_spans return [ Comment(_lststr, _type_to_spans, span, 'Comment') for span in self._subspans('Comment')]
Return a list of found external link objects.
def external_links(self) -> List['ExternalLink']: """Return a list of found external link objects. Note: Templates adjacent to external links are considered part of the link. In reality, this depends on the contents of the template: >>> WikiText( ... ...
Return a list of section in current wikitext.
def sections(self) -> List['Section']: """Return a list of section in current wikitext. The first section will always be the lead section, even if it is an empty string. """ sections = [] # type: List['Section'] sections_append = sections.append type_to_spans = ...
Return a list of found table objects.
def tables(self) -> List['Table']: """Return a list of found table objects.""" tables = [] # type: List['Table'] tables_append = tables.append type_to_spans = self._type_to_spans lststr = self._lststr shadow = self._shadow[:] ss, se = self._span spans = t...
r Return a list of WikiList objects.
def lists(self, pattern: str = None) -> List['WikiList']: r"""Return a list of WikiList objects. :param pattern: The starting pattern for list items. Return all types of lists (ol, ul, and dl) if pattern is None. If pattern is not None, it will be passed to the regex engine, ...
Return all tags with the given name.
def tags(self, name=None) -> List['Tag']: """Return all tags with the given name.""" lststr = self._lststr type_to_spans = self._type_to_spans if name: if name in _tag_extensions: string = lststr[0] return [ Tag(lststr, type...
Yield all the sub - span indices excluding self. _span.
def _subspans(self, _type: str) -> Generator[int, None, None]: """Yield all the sub-span indices excluding self._span.""" ss, se = self._span spans = self._type_to_spans[_type] # Do not yield self._span by bisecting for s < ss. # The second bisect is an optimization and should be...
Return the ancestors of the current node.
def ancestors(self, type_: Optional[str] = None) -> List['WikiText']: """Return the ancestors of the current node. :param type_: the type of the desired ancestors as a string. Currently the following types are supported: {Template, ParserFunction, WikiLink, Comment, Parameter, E...
Return the parent node of the current object.
def parent(self, type_: Optional[str] = None) -> Optional['WikiText']: """Return the parent node of the current object. :param type_: the type of the desired parent object. Currently the following types are supported: {Template, ParserFunction, WikiLink, Comment, Parameter, Exte...
Return the most common item in the list.
def mode(list_: List[T]) -> T: """Return the most common item in the list. Return the first one if there are more than one most common items. Example: >>> mode([1,1,2,2,]) 1 >>> mode([1,2,2]) 2 >>> mode([]) ... ValueError: max() arg is an empty sequence """ return max(...
Return the first argument in the args that has the given name.
def get_arg(name: str, args: Iterable[Argument]) -> Optional[Argument]: """Return the first argument in the args that has the given name. Return None if no such argument is found. As the computation of self.arguments is a little costly, this function was created so that other methods that have already...
Return normal form of self. name.
def normal_name( self, rm_namespaces=('Template',), capital_links=False, _code: str = None, *, code: str = None, capitalize=False ) -> str: """Return normal form of self.name. - Remove comments. - Remove language code. - Remove...
Eliminate duplicate arguments by removing the first occurrences.
def rm_first_of_dup_args(self) -> None: """Eliminate duplicate arguments by removing the first occurrences. Remove the first occurrences of duplicate arguments, regardless of their value. Result of the rendered wikitext should remain the same. Warning: Some meaningful data may be remove...
Remove duplicate arguments in a safe manner.
def rm_dup_args_safe(self, tag: str = None) -> None: """Remove duplicate arguments in a safe manner. Remove the duplicate arguments only in the following situations: 1. Both arguments have the same name AND value. (Remove one of them.) 2. Arguments have the same ...
Set the value for name argument. Add it if it doesn t exist.
def set_arg( self, name: str, value: str, positional: bool = None, before: str = None, after: str = None, preserve_spacing: bool = True ) -> None: """Set the value for `name` argument. Add it if it doesn't exist. - Use `positional`, `before` and `afte...
Return the last argument with the given name.
def get_arg(self, name: str) -> Optional[Argument]: """Return the last argument with the given name. Return None if no argument with that name is found. """ return get_arg(name, reversed(self.arguments))
Return true if the is an arg named name.
def has_arg(self, name: str, value: str = None) -> bool: """Return true if the is an arg named `name`. Also check equality of values if `value` is provided. Note: If you just need to get an argument and you want to LBYL, it's better to get_arg directly and then check if the returne...
Delete all arguments with the given then.
def del_arg(self, name: str) -> None: """Delete all arguments with the given then.""" for arg in reversed(self.arguments): if arg.name.strip(WS) == name.strip(WS): del arg[:]
Build crs table of all equivalent format variations by scraping spatialreference. org. Saves table as tab - delimited text file. NOTE: Might take a while.
def build_crs_table(savepath): """ Build crs table of all equivalent format variations by scraping spatialreference.org. Saves table as tab-delimited text file. NOTE: Might take a while. Arguments: - *savepath*: The absolute or relative filepath to which to save the crs table, including the "....
Lookup crscode on spatialreference. org and return in specified format.
def crscode_to_string(codetype, code, format): """ Lookup crscode on spatialreference.org and return in specified format. Arguments: - *codetype*: "epsg", "esri", or "sr-org". - *code*: The code. - *format*: The crs format of the returned string. One of "ogcwkt", "esriwkt", or "proj4", but als...
Returns the CS as a proj4 formatted string or dict.
def to_proj4(self, as_dict=False, toplevel=True): """ Returns the CS as a proj4 formatted string or dict. Arguments: - **as_dict** (optional): If True, returns the proj4 string as a dict (defaults to False). - **toplevel** (optional): If True, treats this CS as the final toplev...
Returns the CS as a OGC WKT formatted string.
def to_ogc_wkt(self): """ Returns the CS as a OGC WKT formatted string. """ return 'GEOGCS["%s", %s, %s, %s, AXIS["Lon", %s], AXIS["Lat", %s]]' % (self.name, self.datum.to_ogc_wkt(), self.prime_mer.to_ogc_wkt(), self.angunit.to_ogc_wkt(), self.twin_ax[0].ogc_wkt, self.twin_ax[1].ogc_wkt ...
Returns the CS as a ESRI WKT formatted string.
def to_esri_wkt(self): """ Returns the CS as a ESRI WKT formatted string. """ return 'GEOGCS["%s", %s, %s, %s, AXIS["Lon", %s], AXIS["Lat", %s]]' % (self.name, self.datum.to_esri_wkt(), self.prime_mer.to_esri_wkt(), self.angunit.to_esri_wkt(), self.twin_ax[0].esri_wkt, self.twin_ax[1].es...
Returns the CS as a proj4 formatted string or dict.
def to_proj4(self, as_dict=False): """ Returns the CS as a proj4 formatted string or dict. Arguments: - **as_dict** (optional): If True, returns the proj4 string as a dict (defaults to False). """ string = "%s" % self.proj.to_proj4() string += " %s" % self.geogc...
Returns the CS as a OGC WKT formatted string.
def to_ogc_wkt(self): """ Returns the CS as a OGC WKT formatted string. """ string = 'PROJCS["%s", %s, %s, ' % (self.name, self.geogcs.to_ogc_wkt(), self.proj.to_ogc_wkt() ) string += ", ".join(param.to_ogc_wkt() for param in self.params) string += ', %s' % self.unit.to_o...
Returns the CS as a ESRI WKT formatted string.
def to_esri_wkt(self): """ Returns the CS as a ESRI WKT formatted string. """ string = 'PROJCS["%s", %s, %s, ' % (self.name, self.geogcs.to_esri_wkt(), self.proj.to_esri_wkt() ) string += ", ".join(param.to_esri_wkt() for param in self.params) string += ', %s' % self.unit...
Search for a ellipsoid name located in this module.
def find(ellipsname, crstype, strict=False): """ Search for a ellipsoid name located in this module. Arguments: - **ellipsname**: The ellipsoid name to search for. - **crstype**: Which CRS naming convention to search (different CRS formats have different names for the same ellipsoid). ...
Returns the crs object from a string interpreted as a specified format located at a given url site.
def from_url(url, format=None): """ Returns the crs object from a string interpreted as a specified format, located at a given url site. Arguments: - *url*: The url where the crs string is to be read from. - *format* (optional): Which format to parse the crs string as. One of "ogc wkt", "esri wkt...
Returns the crs object from a file with the format determined from the filename extension.
def from_file(filepath): """ Returns the crs object from a file, with the format determined from the filename extension. Arguments: - *filepath*: filepath to be loaded, including extension. """ if filepath.endswith(".prj"): string = open(filepath, "r").read() return parse.from...
Load crs object from epsg code via spatialreference. org. Parses based on the proj4 representation.
def from_epsg_code(code): """ Load crs object from epsg code, via spatialreference.org. Parses based on the proj4 representation. Arguments: - *code*: The EPSG code as an integer. Returns: - A CS instance of the indicated type. """ # must go online (or look up local table) to ge...
Load crs object from esri code via spatialreference. org. Parses based on the proj4 representation.
def from_esri_code(code): """ Load crs object from esri code, via spatialreference.org. Parses based on the proj4 representation. Arguments: - *code*: The ESRI code as an integer. Returns: - A CS instance of the indicated type. """ # must go online (or look up local table) to ge...
Load crs object from sr - org code via spatialreference. org. Parses based on the proj4 representation.
def from_sr_code(code): """ Load crs object from sr-org code, via spatialreference.org. Parses based on the proj4 representation. Arguments: - *code*: The SR-ORG code as an integer. Returns: - A CS instance of the indicated type. """ # must go online (or look up local table) to ...
Internal method for parsing wkt with minor differences depending on ogc or esri style.
def _from_wkt(string, wkttype=None, strict=False): """ Internal method for parsing wkt, with minor differences depending on ogc or esri style. Arguments: - *string*: The OGC or ESRI WKT representation as a string. - *wkttype* (optional): How to parse the WKT string, as either 'ogc', 'esri', or Non...
Parse crs as proj4 formatted string or dict and return the resulting crs object.
def from_proj4(proj4, strict=False): """ Parse crs as proj4 formatted string or dict and return the resulting crs object. Arguments: - *proj4*: The proj4 representation as a string or dict. - *strict* (optional): When True, the parser is strict about names having to match exactly with uppe...
Detect crs string format and parse into crs object with appropriate function.
def from_unknown_text(text, strict=False): """ Detect crs string format and parse into crs object with appropriate function. Arguments: - *text*: The crs text representation of unknown type. - *strict* (optional): When True, the parser is strict about names having to match exactly with up...
Write the raw header content to the out stream
def write_to(self, out): """ Write the raw header content to the out stream Parameters: ---------- out : {file object} The output stream """ out.write(bytes(self.header)) out.write(self.record_data)
Instantiate a RawVLR by reading the content from the data stream
def read_from(cls, data_stream): """ Instantiate a RawVLR by reading the content from the data stream Parameters: ---------- data_stream : {file object} The input stream Returns ------- RawVLR The RawVLR read """ r...
Gets the 3 GeoTiff vlrs from the vlr_list and parse them into a nicer structure
def parse_geo_tiff_keys_from_vlrs(vlr_list: vlrlist.VLRList) -> List[GeoTiffKey]: """ Gets the 3 GeoTiff vlrs from the vlr_list and parse them into a nicer structure Parameters ---------- vlr_list: pylas.vrls.vlrslist.VLRList list of vlrs from a las file Raises ------ IndexError if...
Parses the GeoTiff VLRs information into nicer structs
def parse_geo_tiff( key_dir_vlr: GeoKeyDirectoryVlr, double_vlr: GeoDoubleParamsVlr, ascii_vlr: GeoAsciiParamsVlr, ) -> List[GeoTiffKey]: """ Parses the GeoTiff VLRs information into nicer structs """ geotiff_keys = [] for k in key_dir_vlr.geo_keys: if k.tiff_tag_location == 0: ...
Returns the signedness foe the given type index
def get_signedness_for_extra_dim(type_index): """ Returns the signedness foe the given type index Parameters ---------- type_index: int index of the type as defined in the LAS Specification Returns ------- DimensionSignedness, the enum variant """ try: t = _...
Returns the index of the type as defined in the LAS Specification
def get_id_for_extra_dim_type(type_str): """ Returns the index of the type as defined in the LAS Specification Parameters ---------- type_str: str Returns ------- int index of the type """ try: return _type_to_extra_dim_id_style_1[type_str] except KeyError: ...
Construct a new PackedPointRecord from an existing one with the ability to change to point format while doing so
def from_point_record(cls, other_point_record, new_point_format): """ Construct a new PackedPointRecord from an existing one with the ability to change to point format while doing so """ array = np.zeros_like(other_point_record.array, dtype=new_point_format.dtype) new_record = c...
Tries to copy the values of the current dimensions from other_record
def copy_fields_from(self, other_record): """ Tries to copy the values of the current dimensions from other_record """ for dim_name in self.dimensions_names: try: self[dim_name] = other_record[dim_name] except ValueError: pass
Appends zeros to the points stored if the value we are trying to fit is bigger
def _append_zeros_if_too_small(self, value): """ Appends zeros to the points stored if the value we are trying to fit is bigger """ size_diff = len(value) - len(self.array) if size_diff: self.array = np.append( self.array, np.zeros(size_diff, dtype=sel...
Returns all the dimensions names including the names of sub_fields and their corresponding packed fields
def all_dimensions_names(self): """ Returns all the dimensions names, including the names of sub_fields and their corresponding packed fields """ return frozenset(self.array.dtype.names + tuple(self.sub_fields_dict.keys()))
Creates a new point record with all dimensions initialized to zero
def zeros(cls, point_format, point_count): """ Creates a new point record with all dimensions initialized to zero Parameters ---------- point_format_id: int The point format id the point record should have point_count : int The number of point the point r...
Construct the point record by reading the points from the stream
def from_stream(cls, stream, point_format, count): """ Construct the point record by reading the points from the stream """ points_dtype = point_format.dtype point_data_buffer = bytearray(stream.read(count * points_dtype.itemsize)) try: data = np.frombuffer(point_dat...
Construct the point record by reading and decompressing the points data from the input buffer
def from_compressed_buffer(cls, compressed_buffer, point_format, count, laszip_vlr): """ Construct the point record by reading and decompressing the points data from the input buffer """ point_dtype = point_format.dtype uncompressed = decompress_buffer( compressed_bu...
Returns the scaled x positions of the points as doubles
def x(self): """ Returns the scaled x positions of the points as doubles """ return scale_dimension(self.X, self.header.x_scale, self.header.x_offset)
Returns the scaled y positions of the points as doubles
def y(self): """ Returns the scaled y positions of the points as doubles """ return scale_dimension(self.Y, self.header.y_scale, self.header.y_offset)
Returns the scaled z positions of the points as doubles
def z(self): """ Returns the scaled z positions of the points as doubles """ return scale_dimension(self.Z, self.header.z_scale, self.header.z_offset)
Setter for the points property Takes care of changing the point_format of the file ( as long as the point format of the new points it compatible with the file version )
def points(self, value): """ Setter for the points property, Takes care of changing the point_format of the file (as long as the point format of the new points it compatible with the file version) Parameters ---------- value: numpy.array of the new points """ ...
Adds a new extra dimension to the point record
def add_extra_dim(self, name, type, description=""): """ Adds a new extra dimension to the point record Parameters ---------- name: str the name of the dimension type: str type of the dimension (eg 'uint8') description: str, optional a...
writes the data to a stream
def write_to(self, out_stream, do_compress=False): """ writes the data to a stream Parameters ---------- out_stream: file object the destination stream, implementing the write method do_compress: bool, optional, default False Flag to indicate if you want ...
Writes the las data into a file
def write_to_file(self, filename, do_compress=None): """ Writes the las data into a file Parameters ---------- filename : str The file where the data should be written. do_compress: bool, optional, default None if None the extension of the filename will b...
Writes to a stream or file
def write(self, destination, do_compress=None): """ Writes to a stream or file When destination is a string, it will be interpreted as the path were the file should be written to, also if do_compress is None, the compression will be guessed from the file extension: - .laz -> compressed...
Builds the dict mapping point format id to numpy. dtype In the dtypes bit fields are still packed and need to be unpacked each time you want to access them
def _build_point_formats_dtypes(point_format_dimensions, dimensions_dict): """ Builds the dict mapping point format id to numpy.dtype In the dtypes, bit fields are still packed, and need to be unpacked each time you want to access them """ return { fmt_id: _point_format_to_dtype(point_fmt, d...
Builds the dict mapping point format id to numpy. dtype In the dtypes bit fields are unpacked and can be accessed directly
def _build_unpacked_point_formats_dtypes( point_formats_dimensions, composed_fields_dict, dimensions_dict ): """ Builds the dict mapping point format id to numpy.dtype In the dtypes, bit fields are unpacked and can be accessed directly """ unpacked_dtypes = {} for fmt_id, dim_names in point_...
Tries to find a matching point format id for the input numpy dtype To match the input dtype has to be 100% equal to a point format dtype so all names & dimensions types must match
def np_dtype_to_point_format(dtype, unpacked=False): """ Tries to find a matching point format id for the input numpy dtype To match, the input dtype has to be 100% equal to a point format dtype so all names & dimensions types must match Parameters: ---------- dtype : numpy.dtype The in...
Returns the minimum file version that supports the given point_format_id
def min_file_version_for_point_format(point_format_id): """ Returns the minimum file version that supports the given point_format_id """ for version, point_formats in sorted(VERSION_TO_POINT_FMT.items()): if point_format_id in point_formats: return version else: raise errors...
Returns true if the file version support the point_format_id
def is_point_fmt_compatible_with_version(point_format_id, file_version): """ Returns true if the file version support the point_format_id """ try: return point_format_id in VERSION_TO_POINT_FMT[str(file_version)] except KeyError: raise errors.FileVersionNotSupported(file_version)
Function to get vlrs by user_id and/ or record_ids. Always returns a list even if only one vlr matches the user_id and record_id
def get_by_id(self, user_id="", record_ids=(None,)): """ Function to get vlrs by user_id and/or record_ids. Always returns a list even if only one vlr matches the user_id and record_id >>> import pylas >>> from pylas.vlrs.known import ExtraBytesVlr, WktCoordinateSystemVlr >>> la...
Returns the list of vlrs of the requested type Always returns a list even if there is only one VLR of type vlr_type.
def get(self, vlr_type): """ Returns the list of vlrs of the requested type Always returns a list even if there is only one VLR of type vlr_type. >>> import pylas >>> las = pylas.read("pylastests/extrabytes.las") >>> las.vlrs [<ExtraBytesVlr(extra bytes structs: 5)>] ...
Returns the list of vlrs of the requested type The difference with get is that the returned vlrs will be removed from the list
def extract(self, vlr_type): """ Returns the list of vlrs of the requested type The difference with get is that the returned vlrs will be removed from the list Parameters ---------- vlr_type: str the class name of the vlr Returns ------- ...
Reads vlrs and parse them if possible from the stream
def read_from(cls, data_stream, num_to_read): """ Reads vlrs and parse them if possible from the stream Parameters ---------- data_stream : io.BytesIO stream to read from num_to_read : int number of vlrs to be read Returns ...
Returns true if all the files have the same points format id
def files_have_same_point_format_id(las_files): """ Returns true if all the files have the same points format id """ point_format_found = {las.header.point_format_id for las in las_files} return len(point_format_found) == 1
Returns true if all the files have the same numpy datatype
def files_have_same_dtype(las_files): """ Returns true if all the files have the same numpy datatype """ dtypes = {las.points.dtype for las in las_files} return len(dtypes) == 1
Reads the 4 first bytes of the stream to check that is LASF
def _raise_if_wrong_file_signature(stream): """ Reads the 4 first bytes of the stream to check that is LASF""" file_sig = stream.read(len(headers.LAS_FILE_SIGNATURE)) if file_sig != headers.LAS_FILE_SIGNATURE: raise errors.PylasError( "File Signature ({}) is not {}".format(file_sig, head...
Reads the head of the las file and returns it
def read_header(self): """ Reads the head of the las file and returns it """ self.stream.seek(self.start_pos) return headers.HeaderFactory().read_from_stream(self.stream)
Reads and return the vlrs of the file
def read_vlrs(self): """ Reads and return the vlrs of the file """ self.stream.seek(self.start_pos + self.header.size) return VLRList.read_from(self.stream, num_to_read=self.header.number_of_vlr)
Reads the whole las data ( header vlrs points etc ) and returns a LasData object
def read(self): """ Reads the whole las data (header, vlrs ,points, etc) and returns a LasData object """ vlrs = self.read_vlrs() self._warn_if_not_at_expected_pos( self.header.offset_to_point_data, "end of vlrs", "start of points" ) self.stream.seek(s...
private function to handle reading of the points record parts of the las file.
def _read_points(self, vlrs): """ private function to handle reading of the points record parts of the las file. the header is needed for the point format and number of points the vlrs are need to get the potential laszip vlr as well as the extra bytes vlr """ try: ...
reads the compressed point record
def _read_compressed_points_data(self, laszip_vlr, point_format): """ reads the compressed point record """ offset_to_chunk_table = struct.unpack("<q", self.stream.read(8))[0] size_of_point_data = offset_to_chunk_table - self.stream.tell() if offset_to_chunk_table <= 0: ...
reads and returns the waveform vlr header waveform record
def _read_internal_waveform_packet(self): """ reads and returns the waveform vlr header, waveform record """ # This is strange, the spec says, waveform data packet is in a EVLR # but in the 2 samples I have its a VLR # but also the 2 samples have a wrong user_id (LAS_Spec instea...
Reads the EVLRs of the file will fail if the file version does not support evlrs
def read_evlrs(self): """ Reads the EVLRs of the file, will fail if the file version does not support evlrs """ self.stream.seek(self.start_pos + self.header.start_of_first_evlr) return evlrs.EVLRList.read_from(self.stream, self.header.number_of_evlr)
Helper function to warn about unknown bytes found in the file
def _warn_if_not_at_expected_pos(self, expected_pos, end_of, start_of): """ Helper function to warn about unknown bytes found in the file""" diff = expected_pos - self.stream.tell() if diff != 0: logger.warning( "There are {} bytes between {} and {}".format(diff, end_...
Given a raw_vlr tries to find its corresponding KnownVLR class that can parse its data. If no KnownVLR implementation is found returns a VLR ( record_data will still be bytes )
def vlr_factory(raw_vlr): """ Given a raw_vlr tries to find its corresponding KnownVLR class that can parse its data. If no KnownVLR implementation is found, returns a VLR (record_data will still be bytes) """ user_id = raw_vlr.header.user_id.rstrip(NULL_BYTE).decode() known_vlrs = BaseKnownVLR....
Opens and reads the header of the las content in the source
def open_las(source, closefd=True): """ Opens and reads the header of the las content in the source >>> with open_las('pylastests/simple.las') as f: ... print(f.header.point_format_id) 3 >>> f = open('pylastests/simple.las', mode='rb') >>> with open_las(f, closefd=Fals...
Entry point for reading las data in pylas
def read_las(source, closefd=True): """ Entry point for reading las data in pylas Reads the whole file into memory. >>> las = read_las("pylastests/simple.las") >>> las.classification array([1, 1, 1, ..., 1, 1, 1], dtype=uint8) Parameters ---------- source : str or io.BytesIO T...
Creates a File from an existing header allocating the array of point according to the provided header. The input header is copied.
def create_from_header(header): """ Creates a File from an existing header, allocating the array of point according to the provided header. The input header is copied. Parameters ---------- header : existing header to be used to create the file Returns ------- pylas.lasdatas.base....
Function to create a new empty las data object
def create_las(*, point_format_id=0, file_version=None): """ Function to create a new empty las data object .. note:: If you provide both point_format and file_version an exception will be raised if they are not compatible >>> las = create_las(point_format_id=6,file_version="1.2") Tra...
Converts a Las from one point format to another Automatically upgrades the file version if source file version is not compatible with the new point_format_id
def convert(source_las, *, point_format_id=None, file_version=None): """ Converts a Las from one point format to another Automatically upgrades the file version if source file version is not compatible with the new point_format_id convert to point format 0 >>> las = read_las('pylastests/simple.la...
Merges multiple las files into one
def merge_las(*las_files): """ Merges multiple las files into one merged = merge_las(las_1, las_2) merged = merge_las([las_1, las_2, las_3]) Parameters ---------- las_files: Iterable of LasData or LasData Returns ------- pylas.lasdatas.base.LasBase The result of the mergin...
writes the given las into memory using BytesIO and reads it again returning the newly read file.
def write_then_read_again(las, do_compress=False): """ writes the given las into memory using BytesIO and reads it again, returning the newly read file. Mostly used for testing purposes, without having to write to disk """ out = io.BytesIO() las.write(out, do_compress=do_compress) out.seek...
Returns the creation date stored in the las file
def date(self): """ Returns the creation date stored in the las file Returns ------- datetime.date """ try: return datetime.date(self.creation_year, 1, 1) + datetime.timedelta( self.creation_day_of_year - 1 ) except ValueE...
Returns the date of file creation as a python date object
def date(self, date): """ Returns the date of file creation as a python date object """ self.creation_year = date.year self.creation_day_of_year = date.timetuple().tm_yday
Returns de minimum values of x y z as a numpy array
def mins(self): """ Returns de minimum values of x, y, z as a numpy array """ return np.array([self.x_min, self.y_min, self.z_min])
Sets de minimum values of x y z as a numpy array
def mins(self, value): """ Sets de minimum values of x, y, z as a numpy array """ self.x_min, self.y_min, self.z_min = value
Returns de maximum values of x y z as a numpy array
def maxs(self): """ Returns de maximum values of x, y, z as a numpy array """ return np.array([self.x_max, self.y_max, self.z_max])
Sets de maximum values of x y z as a numpy array
def maxs(self, value): """ Sets de maximum values of x, y, z as a numpy array """ self.x_max, self.y_max, self.z_max = value
Returns the scaling values of x y z as a numpy array
def scales(self): """ Returns the scaling values of x, y, z as a numpy array """ return np.array([self.x_scale, self.y_scale, self.z_scale])
Returns the offsets values of x y z as a numpy array
def offsets(self): """ Returns the offsets values of x, y, z as a numpy array """ return np.array([self.x_offset, self.y_offset, self.z_offset])
>>> HeaderFactory. header_class_for_version ( 2. 0 ) Traceback ( most recent call last ):... pylas. errors. FileVersionNotSupported: 2. 0
def header_class_for_version(cls, version): """ >>> HeaderFactory.header_class_for_version(2.0) Traceback (most recent call last): ... pylas.errors.FileVersionNotSupported: 2.0 >>> HeaderFactory.header_class_for_version(1.2) <class 'pylas.headers.rawheader.RawHe...
seeks to the position of the las version header fields in the stream and returns it as a str
def peek_file_version(cls, stream): """ seeks to the position of the las version header fields in the stream and returns it as a str Parameters ---------- stream io.BytesIO Returns ------- str file version read from the stream """ ...
Converts a header to a another version
def convert_header(cls, old_header, new_version): """ Converts a header to a another version Parameters ---------- old_header: the old header instance new_version: float or str Returns ------- The converted header >>> old_header = HeaderFactory...
Unpack sub field using its mask
def unpack(source_array, mask, dtype=np.uint8): """ Unpack sub field using its mask Parameters: ---------- source_array : numpy.ndarray The source array mask : mask (ie: 0b00001111) Mask of the sub field to be extracted from the source array Returns ------- numpy.ndarray...