pyoints.storage package

Submodules

pyoints.storage.BaseGeoHandler module

Basic handling of spatial files.

class pyoints.storage.BaseGeoHandler.GeoFile(infile, directory=False)[source]

Bases: object

Interface to read files containing spatial information.

Parameters:
  • infile (String) – File to be read. It should contain data to be interpreted as points of k dimensions.
  • directory (bool) – Indicates if the file is a composite of several files stored in a directory.
  • Properties
  • ----------
  • t (np.matrix(Number, shape=(k+1, k+1))) – Transformation matrix to transform the k-dimensional points. Usually this matrix defines the origin of a local coordinate system.
  • proj (Proj) – Coordinate projection system.
  • extent (Extent(Number, shape=(2 * k))) – Defines the spatial extent of the points.
  • corners (np.ndarray(Number, shape=(2**k, k))) – Corners of the extent.
  • date (datetime) – Date of capture.

See also

Proj, Extent

clean_cache()[source]

Cleans all cached data.

corners
date
extent
load(extent=None)[source]

Load data on demand.

Parameters:extent (optional, array_like(Number, shape=(2*self.dim))) – Defines in which volume or area points shall be loaded.
Returns:Desired geo-data of the file.
Return type:GeoRecords
proj
t

pyoints.storage.CsvHandler module

pyoints.storage.CsvHandler.loadCsv(infile, sep=', ', multicol_sep='.', dtype=None, header=True, ignore='# ', **kwargs)[source]

Simplified loading of .csv files.

Parameters:
  • infile (String) – File to be read.
  • sep (optional, Character) – Character separating the columns.
  • multicol_sep (optional, Character) – Indicates how the column index of multi-column are separated form the column name.
  • dtype (np.dtype) – Desired data type of the output numpy record array.
  • header (bool) – Indicates
  • **kwargs (optional) – Arguments passed to pandas.read_csv.
Returns:

Loaded data.

Return type:

np.recarary

See also

writeCsv(), pandas.read_csv()

pyoints.storage.CsvHandler.writeCsv(data, outfile, sep=', ', multicol_sep='.', **kwargs)[source]

Write an array to a csv-file.

Parameters:
  • data (array_like) – Data to store.
  • outfile (string) – File to write the data to.
  • sep (optional, Character) – Desired field separator.
  • multicol_sep (optional, Character) – Indicates how the column index of multi-column shall be separated form the column name. For example, the column names ‘normal.1’, ‘normal.2’ indicate a two dimensional attribute ‘normal’.
  • **kwargs (optional) – Arguments passed to np.save_txt`

See also

loadCsv(), np.save_txt()

Notes

Limited type validation.

pyoints.storage.DumpHandler module

class pyoints.storage.DumpHandler.DumpReader(filename)[source]

Bases: pyoints.storage.BaseGeoHandler.GeoFile

Class to read GeoRecords from python dump files.

See also

GeoFile

clean_cache()[source]

Cleans all cached data.

corners
extent
load()[source]

Load data on demand.

Parameters:extent (optional, array_like(Number, shape=(2*self.dim))) – Defines in which volume or area points shall be loaded.
Returns:Desired geo-data of the file.
Return type:GeoRecords
proj
t
pyoints.storage.DumpHandler.dumpstring_from_object(data)[source]

Converts an object to a dump string.

Parameters:string (string) – Dump string
Returns:Dump string.
Return type:string
pyoints.storage.DumpHandler.dumpstring_to_object(pickled)[source]

Converts a dump string to an object.

Parameters:string (string) – Dump string
Returns:Loaded object.
Return type:object
pyoints.storage.DumpHandler.loadDump(filename)[source]

Loads a dump file.

Parameters:filename (String) – Dump file to load.
Returns:
Return type:object
pyoints.storage.DumpHandler.writeDump(obj, filename)[source]

Dump an object to a file.

Parameters:
  • obj (object) – Object to dump
  • outfile (String) – File to dump object to.

pyoints.storage.LasHandler module

Handling of .las-files.

class pyoints.storage.LasHandler.LasReader(infile, proj=None)[source]

Bases: pyoints.storage.BaseGeoHandler.GeoFile

Class to read .las-files.

Parameters:
  • infile (String) – Las file to be read.
  • proj (optional, Proj) – Spatial reference system. Usually provided only, if the spatial reference of the file has not be set yet.

See also

GeoFile

corners
extent
load(extent=None)[source]

Load data on demand.

Parameters:extent (optional, array_like(Number, shape=(2*self.dim))) – Defines in which volume or area points shall be loaded.
Returns:Desired geo-data of the file.
Return type:GeoRecords
pyoints.storage.LasHandler.writeLas(geoRecords, outfile, point_format=3)[source]

Write a LAS file to disc.

Parameters:
  • geoRecords (GeoRecords) – Points to store to disk.
  • outfile (String) – Desired output file.
  • point_format (optional, positive int) – Desired LAS point format. See LAS specification for details.

pyoints.storage.PlyHandler module

Handling of .ply-files.

pyoints.storage.PlyHandler.loadPly(infile, proj=<pyoints.projection.Proj object>)[source]

Loads a .ply file.

Parameters:infile (String) – PLY-file to be read.
Returns:Loaded data.
Return type:np.recarray

See also

writePly()

pyoints.storage.PlyHandler.writePly(rec, outfile)[source]

Saves data to a .ply file.

Parameters:
  • rec (np.recarray) – Numpy record array to save.
  • outfile (String) – Desired output .ply file .

See also

loadPly()

pyoints.storage.RasterHandler module

class pyoints.storage.RasterHandler.RasterReader(infile, proj=None, date=None)[source]

Bases: pyoints.storage.BaseGeoHandler.GeoFile

Reads image files.

Parameters:
  • infile (String) – Raster file to be read.
  • proj (optional, Proj) – Spatial reference system. Usually just provided, if the spatial reference has not been set yet.
  • date (datetime.date) – Date of capture.

See also

GeoFile

corners
extent
load(extent=None)[source]

Load data on demand.

Parameters:extent (optional, array_like(Number, shape=(2*self.dim))) – Defines in which volume or area points shall be loaded.
Returns:Desired geo-data of the file.
Return type:GeoRecords
num_bands
pyoints.storage.RasterHandler.load_gdal(filename, proj=None, extent=None)[source]

Loads an image from disc using gdal.

Parameters:
  • filename (str) – Path to file.
  • proj (optional, Proj) – Desired projection.
  • extent (optional, array_like(Number, shape=(4))) – Desired extent to load.
Returns:

  • bands (np.array(Number, (rows, cols, bands))) – Image data.
  • rotation (Number) – Image orientation.
  • proj (Proj) – Projection.

pyoints.storage.RasterHandler.writeRaster(raster, outfile, field='bands', no_data=None)[source]

Writes a Grid to file system.

Parameters:
  • raster (Grid(shape=(cols, rows))) – A two dimensional Grid of cols columns and rows rows to be stored.
  • outfile (String) – File to save the raster to.
  • field (optional, str) – Field considered as raster bands.
  • no_data (optional, Number) – Desired no data value.
Raises:

IOError

See also

writeTif()

pyoints.storage.RasterHandler.write_gdal(image, outfile, T=None, proj=None, no_data=None, driver='GTiff')[source]

Writes an image to disc.

Parameters:
  • image (np.ndarray(Number, shape=(rows, cols, k))) – Image to save
  • outfile (String) – File to save the raster to.
  • T (optional, array_like(Number, shape=(3, 3))) – Projection matrix to be used.
  • proj (Proj) – Projection to be used.
  • no_data (optional, Number) – No data value to be used.
  • driver (optional, str) – Gdal driver.
Raises:

IOError

See also

writeRaster()

pyoints.storage.dtype_converters module

Helper functions for data type conersion.

pyoints.storage.dtype_converters.numpy_to_gdal_dtype(dtype)[source]

Converts a numpy data type to a gdal data type.

Parameters:dtype (np.dtype) – Numpy data type to convert.
Returns:Gdal data type id.
Return type:int

Examples

>>> dtype = np.dtype(np.int32)
>>> print(numpy_to_gdal_dtype(dtype))
5
pyoints.storage.dtype_converters.numpy_to_laspy_dtype(dtype)[source]

Converts a numpy data type to a laspy data type.

Parameters:dtype (np.dtype) – Numpy data type to convert.
Returns:Laspy data type id.
Return type:int

Examples

>>> dtype = np.dtype(np.int32)
>>> print(numpy_to_laspy_dtype(dtype))
6

pyoints.storage.misc module

Some random functions, which ease development.

pyoints.storage.misc.create_random_GeoRecords(center=None, epsg=25832, dim=3, n=1000, scale=10)[source]

pyoints.storage.structured module

Reading and writing of common structured file types.

pyoints.storage.structured.loadJson(infile)[source]

Loads a JSON file from disc.

Parameters:infile (str) – Input file.
Returns:File data.
Return type:dict
pyoints.storage.structured.writeJson(data, outfile)[source]

Writes a JSON file to disk.

Parameters:
  • data (dict) – JSON compatible data to store.
  • outfile (str) – Output JSON file.

Module contents

Loading and saving of files.