~tfardet/pycafe

f9353368275dc2b9043102fd8aeab5639a336c9e — Tanguy Fardet 3 months ago ddd7671
Move to GeoDataFrame only
2 files changed, 12 insertions(+), 12 deletions(-)

M _deposits.py
M plot/local_deposits.py
M _deposits.py => _deposits.py +11 -11
@@ 16,6 16,7 @@ import pandas as pd
import pint
import pint_pandas

from geopandas import GeoDataFrame
from orgmatt.nutrients import nutrient_from_population as nfp

from .units import *


@@ 38,7 39,7 @@ Nutrients = Literal["N", "P", "K"] | Sequence[Literal["N", "P", "K"]]

def local_deposits(
    country: str,
    area: str | Iterable | gpd.GeoDataFrame,
    area: GeoDataFrame,
    days: dict[str, int],
    admin_level: int | None = None,
    ci: int = 0,


@@ 100,21 101,20 @@ def local_deposits(
    # iterative calls if multiple areas
    multiarea = True

    if isinstance(area, str):
        multiarea = False
    elif isinstance(area, gpd.GeoDataFrame):
    print(area)

    if isinstance(area, gpd.GeoDataFrame):
        multiarea = (len(area) > 1)

        if multiarea:
            # order biggest cities first
            order = list(range(len(area)))
    if multiarea:
        # order biggest cities first
        order = list(range(len(area)))

            if "population" in area:
                order = np.argsort(area.population)[::-1]
        if "population" in area:
            order = np.argsort(area.population)[::-1]

            area = [area.iloc[[i]].reset_index(drop=True) for i in order]
        area = [area.iloc[[i]].reset_index(drop=True) for i in order]

    if multiarea:
        # configure progress bar
        pbar_name = "Computing deposits"


M plot/local_deposits.py => plot/local_deposits.py +1 -1
@@ 377,7 377,7 @@ def plot_map_deposits(

        pstr = translate("population", lang)

        subtitle = area_name + ", " if area_name else "" \
        subtitle = (area_name + ", " if area_name else "") \
            + f"{pstr}: {int(res_pop):_d}"

        # add thousand separator