:py:mod:`ecoscope.base.utils` ============================= .. py:module:: ecoscope.base.utils Module Contents --------------- .. py:function:: create_meshgrid(aoi, in_crs, out_crs, xlen=1000, ylen=1000, return_intersecting_only=True, align_to_existing=None) Create a grid covering `aoi`. :param aoi: The area of interest. Should be in a UTM CRS. :type aoi: shapely.geometry.base.BaseGeometry :param in_crs: Coordinate Reference System of input `aoi`. Can be anything accepted by `pyproj.CRS.from_user_input()`. Geometry is automatically converted to UTM CRS as an intermediate for computation. :type in_crs: value :param out_crs: Coordinate Reference System of output `gs`. Can be anything accepted by `pyproj.CRS.from_user_input()`. Geometry is automatically converted to UTM CRS as an intermediate for computation. :type out_crs: value :param xlen: The width of a grid cell in meters. :type xlen: int, optional :param ylen: The height of a grid cell in meters. :type ylen: int, optional :param return_intersecting_only: Whether to return only grid cells intersecting with the aoi. :type return_intersecting_only: bool, optional :param align_to_existing: If provided, attempts to align created grid to start of existing grid. Requires a CRS and valid geometry. :type align_to_existing: geopandas.GeoSeries or geopandas.GeoDataFrame, optional :returns: **gs** -- Grid of boxes. CRS is converted to `out_crs`. :rtype: geopandas.GeoSeries .. py:class:: cachedproperty(func) The ``cachedproperty`` is used similar to :class:`property`, except that the wrapped method is only called once. This is commonly used to implement lazy attributes. .. py:method:: __doc__() .. py:method:: __isabstractmethod__() .. py:method:: __get__(obj, objtype=None) .. py:method:: __repr__() Return repr(self). .. py:function:: groupby_intervals(df, col, intervals) :param df: Data to group :type df: pd.DataFrame :param col: Name of column to group on :type col: str :param intervals: Intervals to group on :type intervals: pd.IntervalIndex :rtype: pd.core.groupby.DataFrameGroupBy .. py:function:: create_interval_index(start, intervals, freq, overlap=pd.Timedelta(0), closed='right', round_down_to_freq=False) :param start: Left bound for creating IntervalIndex :type start: str or datetime-like :param intervals: Number of intervals to create :type intervals: int, optional :param freq: Length of each interval :type freq: str, Timedelta or DateOffset :param overlap: Length of overlap between intervals :type overlap: Timedelta or DateOffset, optional :param closed: Whether the intervals are closed on the left-side, right-side, both or neither :type closed: {"left", "right", "both", "neither"}, default "right" :param round_down_to_freq: Start will be rounded down to freq :type round_down_to_freq: bool :returns: **interval_index** :rtype: pd.IntervalIndex .. py:class:: ModisBegin Bases: :py:obj:`pandas._libs.tslibs.offsets.SingleConstructorOffset` Primitive DateOffset to support MODIS period start times. .. py:method:: apply(other) .. py:function:: create_modis_interval_index(start, intervals, overlap=pd.Timedelta(0), closed='right') :param start: Left bound for creating IntervalIndex. Will be rounded up to next start of MODIS period :type start: str or datetime-like :param intervals: Number of intervals to create :type intervals: int, optional :param overlap: Length of overlap between intervals :type overlap: Timedelta or DateOffset, optional :param closed: Whether the intervals are closed on the left-side, right-side, both or neither :type closed: {"left", "right", "both", "neither"}, default "right" :returns: **interval_index** :rtype: pd.IntervalIndex .. py:function:: add_val_index(df, index_name, val) :param df: Dataframe to create index on :type df: pd.DataFrame :param index_name: Name of index :type index_name: str :param val: Current column to rename and set as index :type val: str :rtype: pd.DataFrame .. py:function:: add_temporal_index(df, index_name, time_col, directive) :param df: Dataframe to create index on :type df: pd.DataFrame :param index_name: Name of temporal index :type index_name: str :param time_col: Name of the time column :type time_col: str :param directive: Time format string :type directive: str :rtype: pd.DataFrame