load_any#
- geobricks.load_any(data, *, name=None, decode_coords='all', decode_times=True, rebuild_time_val=True, **kwargs)[source]#
This function loads any common spatio-temporal file or variable into a standard python variable, without the need to think about the file or variable type.
Parameters#
- datapath (str or pathlib.Path), or variable (xarray.Dataset, xarray.DataArray, geopandas.GeoDataFrame, pandas.DataFrame or numpy.array)
data
will be loaded into a standard GEOP4TH variable:all vector data (GeoPackage, shapefile, GeoJSON) will be loaded as a geopandas.GeoDataFrame
all raster data (ASCII, GeoTIFF) and netCDF will be loaded as a xarray.Dataset
other data will be loaded either as a pandas.DataFrame (CSV and JSON) or as a numpy.array (TIFF)
If
data
is already a variable, no operation will be executed.- namestr, optional, default None
Name of the main variable for TIFF, GeoTIFF or ASCII files.
- decode_coordsbool or {“coordinates”, “all”}, default “all”
Controls which variables are set as coordinate variables:
“coordinates” or True: Set variables referred to in the
'coordinates'
attribute of the datasets or individual variables as coordinate variables.“all”: Set variables referred to in
'grid_mapping'
,'bounds'
and other attributes as coordinate variables.
Only existing variables can be set as coordinates. Missing variables will be silently ignored.
Despite it is an argument for xarray.open_dataset, this argument is explicitely passed outside the following
**kwargs
arguments because the default value in geop4th is different from the default value in xarray.open_dataset.- decode_timesbool, default True
If True, decode times encoded in the standard NetCDF datetime format into datetime objects.
Despite it is an argument for xarray.open_dataset, this argument is explicitely passed outside the following
**kwargs
arguments because the default value in GEOP4TH is different from the default value in xarray.open_dataset.- rebuild_time_valbool, default True
If True, infer the time coordinate as a datetime object, from available information.
- **kwargs
Optional other arguments passed to
xarray.open_dataset
,pandas.DataFrame.read_csv
,pandas.DataFrame.to_csv
,pandas.DataFrame.read_json
orpandas.DataFrame.to_json
function calls.May contain:
decode_cf
sep
encoding
force_ascii
…
>>> help(xarray.open_dataset) >>> help(pandas.read_csv) >>> help(pandas.to_csv) >>> ...
Returns#
- data_dsgeopandas.GeoDataFrame, xarray.Dataset, pandas.DataFrame or numpy.array
Data is loaded into a GEOP4TH variable. The type of this variable is accordingly to the type of data:
all vector data will be loaded as a geopandas.GeoDataFrame
all raster data and netCDF will be loaded as a xarray.Dataset
other data will be loaded either as a pandas.DataFrame (CSV and JSON) or as a numpy.array (TIFF)
Examples#
>>> data_ds = geo.load_any(r'D:\data.nc') >>> data_ds.head() ...