Skip to content

Unit options

King, Jonathan M requested to merge ghsc/users/jking/pfdf:units2 into main

Notes for reviewer

This MR adds additional support for metric/imperial units to pfdf. Formerly, users could use CRS base units or optionally meters when returning/inputting values. This MR expands these options to include kilometers, feet, and miles, and makes space for additional units for future development. The MR also reorganizes some of the backend to facilitate future development, but this does not affect the functionality of the package.

Closes #89 (closed), #98 (closed), #140 (closed), #142 (closed), #143 (closed), #144 (closed), #145 (closed)

Unit Modules

_utils.units and utils.units are new and provide the functionality for unit conversion.

Low Level

projection._crs: base_to_units and units_to_base convert between CRS units and user-specified units. They replace the former functions which could only convert between base units and meters.

_validate._misc.units checks that user-specified units are supported.

Commands with units

Formerly, all of these functions included a base_unit or meters option to provide values in the non-default unit system. They have all been updated to use a units option instead, which allows the user to specify the desired units.

projection.transform.Transform: dx, dy, xres, yres, resolution, pixel_area, pixel_diagonal

projection.bbox.BoundingBox: xdisp, ydisp, width, height, buffer, dx, dy

raster._raster.Raster: dx, dy, resolution, pixel_area, pixel_diagonal, from_points, from_polygons, buffer

watershed: network

segments._segments.Segments: init, area, burned_area, developed_area, length

Edited by King, Jonathan M

Merge request reports

Loading