How to use tobler - 4 common examples

To help you get started, we’ve selected a few tobler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spatialucr / geosnap / geosnap / harmonize / harmonize.py View on Github external
allocate_total=allocate_total,
            )

        elif weights_method == "land_type_area":
            try:

                area_tables_raster_fitted = area_tables_raster(
                    source_df,
                    target_df.copy(),
                    raster_path=raster,
                    codes=codes,
                    force_crs_match=force_crs_match,
                )

                # In area_interpolate, the resulting variable has same lenght as target_df
                interpolation = _slow_area_interpolate(
                    source_df,
                    target_df.copy(),
                    extensive_variables=extensive_variables,
                    intensive_variables=intensive_variables,
                    allocate_total=allocate_total,
                    tables=area_tables_raster_fitted,
                )
            except IOError:
                raise IOError(
                    "You must have NLCD raster data installed locally to use the"
                    "`land_type_area` method. You can install it using the"
                    "`tobler.data.store_rasters()` function from the `tobler` package"
                )
        else:
            raise ValueError('weights_method must of one of ["area", "land_type_area"]')
github spatialucr / geosnap / geosnap / harmonize / harmonize.py View on Github external
_check_presence_of_crs(raw_community)
    dfs = raw_community.copy()
    times = dfs[time_col].unique()

    target_df = dfs[dfs[time_col] == target_year].reset_index()

    interpolated_dfs = {}
    interpolated_dfs[target_year] = target_df.copy()

    for i in times:
        source_df = dfs[dfs[time_col] == i]

        if weights_method == "area":

            # In area_interpolate, the resulting variable has same lenght as target_df
            interpolation = area_interpolate(
                source_df,
                target_df.copy(),
                extensive_variables=extensive_variables,
                intensive_variables=intensive_variables,
                allocate_total=allocate_total,
            )

        elif weights_method == "land_type_area":
            try:

                area_tables_raster_fitted = area_tables_raster(
                    source_df,
                    target_df.copy(),
                    raster_path=raster,
                    codes=codes,
                    force_crs_match=force_crs_match,
github spatialucr / geosnap / geosnap / harmonize / harmonize.py View on Github external
if weights_method == "area":

            # In area_interpolate, the resulting variable has same lenght as target_df
            interpolation = area_interpolate(
                source_df,
                target_df.copy(),
                extensive_variables=extensive_variables,
                intensive_variables=intensive_variables,
                allocate_total=allocate_total,
            )

        elif weights_method == "land_type_area":
            try:

                area_tables_raster_fitted = area_tables_raster(
                    source_df,
                    target_df.copy(),
                    raster_path=raster,
                    codes=codes,
                    force_crs_match=force_crs_match,
                )

                # In area_interpolate, the resulting variable has same lenght as target_df
                interpolation = _slow_area_interpolate(
                    source_df,
                    target_df.copy(),
                    extensive_variables=extensive_variables,
                    intensive_variables=intensive_variables,
                    allocate_total=allocate_total,
                    tables=area_tables_raster_fitted,
                )
github spatialucr / geosnap / geosnap / harmonize / harmonize.py View on Github external
where a_i is the total area of source polygon i.

        For an intensive variable, the estimate at target polygon j is:

        v_j = \sum_i v_i w_{i,j}

        w_{i,j} = a_{i,j} / \sum_k a_{k,j}

    """
    if extensive_variables is None and intensive_variables is None:
        raise ValueError(
            "You must pass a set of extensive and/or intensive variables to interpolate"
        )

    _check_presence_of_crs(raw_community)
    dfs = raw_community.copy()
    times = dfs[time_col].unique()

    target_df = dfs[dfs[time_col] == target_year].reset_index()

    interpolated_dfs = {}
    interpolated_dfs[target_year] = target_df.copy()

    for i in times:
        source_df = dfs[dfs[time_col] == i]

        if weights_method == "area":

            # In area_interpolate, the resulting variable has same lenght as target_df
            interpolation = area_interpolate(
                source_df,

tobler

Tobler is a Python library for areal interpolation.

BSD-3-Clause
Latest version published 5 days ago

Package Health Score

75 / 100
Full package analysis

Similar packages