gps_data_analyzer.raster_analysis module

class gps_data_analyzer.raster_analysis.Extent(xmin, xmax, ymin, ymax, border=0)

Bases: object

Class to manage extent of a Raster data and generate a mesh.

inner_xmin

The minimum X coordinate not considering the border.

Type

float

inner_xmax

The maximum X coordinate not considering the border.

Type

float

inner_ymin

The minimum Y coordinate not considering the border.

Type

float

inner_ymax

The maximum Y coordinate not considering the border.

Type

float

xmin

The minimum X coordinate considering the border.

Type

float

xmax

The maximum X coordinate considering the border.

Type

float

ymin

The minimum Y coordinate considering the border.

Type

float

ymax

The maximum Y coordinate considering the border.

Type

float

border

The extra border to add around the data values.

Type

float

Parameters
  • xmin (float) – The minimum X coordinate.

  • xmax (float) – The maximum X coordinate.

  • ymin (float) – The minimum Y coordinate.

  • ymax (float) – The maximum Y coordinate.

  • border (float, optional) – The extra border to add around the data values.

mesh(mesh_size=None, x_size=None, y_size=None, nx=None, ny=None)

Create a mesh in the current extent.

Parameters
  • mesh_size (float, optional) – The space between two pixels of the heatmap.

  • x_size (float, optional) – The space between two pixels of the heatmap along the X axis.

  • y_size (float, optional) – The space between two pixels of the heatmap along the Y axis.

  • nx (int, optional) – The number of pixels of the heatmap along the X axis.

  • ny (int, optional) – The number of pixels of the heatmap along the Y axis.

Returns

X and Y coordinates of the mesh nodes.

Return type

(numpy.array, numpy.array)

project(current_proj, new_proj)

Create a new Extent instance after projection.

Parameters
  • current_proj (pyproj.proj.Proj or int) – The current projection.

  • new_proj (pyproj.proj.Proj or int) – The target projection.

Returns

The projected extent.

Return type

Extent

reset_border(border)

Define new extent and recalculate the extent according to it.

Parameters

border (float) – The extra border to add around the data values.

property xmax
property xmin
property ymax
property ymin
class gps_data_analyzer.raster_analysis.Raster(X, Y, values, extent, crs=None)

Bases: object

Class to manage Raster data.

X

The default EPSG code of input data (only used when input_crs is None).

Type

int

Y

The default column name of input data that contains X coordinates (only used when x_col is None).

Type

str

values

The default column name of input data that contains Y coordinates (only used when y_col is None).

Type

str

extent

The default column name of input data that contains Z coordinates (only used when z_col is None and _has_z is True).

Type

str

Parameters
  • X (numpy.array) – The X coordinates.

  • Y (numpy.array) – The Y coordinates.

  • values (numpy.array) – The values at each point (X, Y).

  • extent (Extent) – The extent of the raster data.

static _load(path)
plot(ax=None, show=True, cmap=None, background=False, zoom=None, annotations=None, annotation_kwargs=None, **kwargs)

Plot raster with background and annotations.

Parameters
  • ax (matplotlib.pyplot.Axes, optional) – The axis object to update.

  • show (bool, optional) – If true, call plt.show() else return the figure and axis objects.

  • cmap (matplotlib.colors.Colormap, optional) – The colormap to use (a default will be created if not given).

  • background (bool or cartopy.io.img_tiles.GoogleWTS, optional) – If true, a default background is added using Google Satellite. If a GoogleWTS object is given, it is used.

  • zoom (int, mandatory if background is not None) – The zoom value used to generate the background.

  • annotations (PoiPoints, optional) – The points used to annotate the figure.

  • annotation_kwargs (dict, optional) – The kwargs passed to add_annotated_points().

  • kwargs – The given kwargs will be passed to matplotlib.pyplot.Axes.imshow().

Returns

Raster The 2D array containing the result.

save(path)
gps_data_analyzer.raster_analysis.heatmap(gps_data, mesh_size=None, x_size=None, y_size=None, nx=None, ny=None, border=0, kernel_size=None, kernel_cut=4.0, weight_col=None, normalize=True)

Compute heatmap from a set of points using a Gaussian kernel.

Parameters
  • gps_data (_GpsBase) – The point set.

  • mesh_size (float, optional) – The space between two pixels of the heatmap.

  • x_size (float, optional) – The space between two pixels of the heatmap along the X axis.

  • y_size (float, optional) – The space between two pixels of the heatmap along the Y axis.

  • nx (int, optional) – The number of pixels of the heatmap along the X axis.

  • ny (int, optional) – The number of pixels of the heatmap along the Y axis.

  • border (float, optional) – The extra border around the data.

  • kernel_size (float, optional) – The kernel size used for computation.

  • kernel_cut (float, optional) – The kernel cut used for computation.

  • weight_col (str, optional) – The column name used as point weights.

  • normalize (bool, optional) – Trigger normalization of the result.

Returns

Raster The 2D array containing the result.

gps_data_analyzer.raster_analysis.load_raster(path: str) → gps_data_analyzer.raster_analysis.Raster

Load Raster from a file.

Parameters

path (str) – The path to the file.

Returns

The data loaded.

Return type

Raster