geoutil module

The geoutil module is used to store geographical coordinates of a DAS fiber channel in a simple way and to make them available to QGIS.

Save coordinates

geoutil.save_location_as_h5(filename, position, dist, trace, crs, pos_label, tgte=None)

Description

Save (or append) fiber location information to a h5 file by adding/replacing the group “/location” and adding/replacing attributes.

content of the group /location:
  • datasets:
    • /location/position: (x,y,z)

    • /location/trace: trace_index

    • /location/dist: curvilinear abscissa

  • attributes:
    • crs: coordinate reference system

    • pos_label: (x,y,z) labels

    • tgte: optional, tangent vector in 3D space

Input

filename:

(str) file to store location information. If data_filename is not defined, it is assumed to be the same as filename, and location information is appended to it.

position:

(ndarray, float) [3 x ntraces] (x,y,z) or (lat,lon,z) or (.,.,.) for each trace

dist:

(ndarray, float) [ntraces] curvilinear abscissa

trace:

(ndarray, int) [ntraces] index of traces

crs:

(str) coordinate reference system using EPSG ids (see https://epsg.io, ex “EPSG:3857” for WGS 84 / Pseudo-Mercator)

labels:

(tuple) lables for the three coordinates (ex: (‘x’,’y’,’z’) or (‘lat’,’lon’,’elev’)

geoutil.save_location_as_wkt(fileout, positions, crs, distance=None)

Definition

Save location information in a .csv file using WellKnownText convention to be read by QGIS. Positions are supposed to be passed as (x,y,z) or (lat,lon,z) according to reference coordinate system

Input

fileout:

(str) filename without suffix

positions:

(ndarray) of size 3 x ntrace

crs:

(str) reference coordinate system in the form EPGS:#### or ####, only the number #### is used

distance:

distance along fiber (optional)

geoutil.save_location_as_gpkg(fileout, position, dist, trace, crs, tgte=None)

Description

Save fiber location information using the geo-package format (.gpkg) which can be directly imported into QGIS. This requires the ‘geopandas’ package

Input

position:

(ndarray, float) [3 x nspace] x,y,z where (x,y) depends on the reference coordinate system

dist:

(ndarray, float) [nspace] curvilinear abscissa

trace:

(ndarray, int) [nspace] trace index

crs:

(str) coordinate reference system in the standard form ‘EPGS:####’

tgte:

optional,(ndarray, float) [3 x nspace]; tangent vector to the fiber

Load coordinates

geoutil.read_location_from_h5(filename)

Description

Read fiber location information from a h5 file

returns:
positions:

ndarray of size 3 x ntrace (x,y,z for each trace)

dist:

ndarray of size ntrace (curvilinear distance for each trace)

trace:

ndarray of size ntrace (trace index)

tgte:

(optional) ndarray of size 3 x ntrace (tangent vector to the fiber)

crs:

(str) reference coordinate system

pos_label:

(tuple of str) labels for the 3 positions (‘x’,’y’,’z’) or (‘lat’,’lon’,’elev’) or …

geoutil.read_location_from_gpkg(file)

Description

Read fiber location information from a .gpkg (geopackage used by QGIS) file

returns:
  • position (a numpy ndarray of size [3 x npoints] or [2 x npoints] if elevation is not known)

  • crs (coordinate reference system)