standardize_space_coords#
- geobricks.standardize_space_coords(data, *, var=None, infer_from='dims', to_file=False)[source]#
Use standard x and y variables as the space coordinates. Standardize their names into ‘x’ and ‘y’ (or ‘lat’ and ‘lon’). If not a dimension, make them dimensions.
Parameters#
- datapath (str or pathlib.Path), or variable (xarray.Dataset, xarray.DataArray, geopandas.GeoDataFrame, geopandas.GeoSeries, pandas.DataFrame or pandas.Series)
Data whose temporal coordinate should be renamed.
- vartuple of str, optional
Variables to rename into ‘x’ and ‘y’. If not specified, the variable that will be renamed into ‘x’ and ‘y’ will be inferred from the detected time coordinate(s).
- infer_from{‘dims’, ‘coords’, ‘all’}, default ‘dims’
To specify if the space coordinates should be infered from dimensions, coordinates or all variables (coordinates and data variables).
- to_filebool or path (str or pathlib.Path), default False
If True and if
datais a path (str or pathlib.Path), the resulting dataset will be exported to a file with the same pathname and the suffix ‘_std_time’. Ifto_fileis a path, the resulting dataset will be exported to this specified filepath.
Returns#
- geopandas.GeoDataFrame, xarray.Dataset or pandas.DataFrame
Data with the modified name for the temporal coordinate. The variable type will be accordingly to the variable type of input
data.
If
to_fileargument is used, the resulting dataset can also be exported to a file.