How to use the mapclassify.UserDefined function in mapclassify

To help you get started, we’ve selected a few mapclassify 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 martinfleis / momepy / momepy / diversity.py View on Github external
except ImportError:
            raise ImportError("The 'mapclassify' package is required")

    def p(n, N):
        """ Relative abundance """
        if n == 0:
            return 0
        return float(n) / N

    if categorical:
        counts = data.value_counts().to_dict()
        for c in categories:
            if c not in counts.keys():
                counts[c] = 0
    else:
        sample_bins = mc.UserDefined(data, bins)
        counts = dict(zip(bins, sample_bins.counts))

    N = sum(counts.values())

    return sum(p(n, N) ** 2 for n in counts.values() if n != 0)
github martinfleis / momepy / momepy / diversity.py View on Github external
except ImportError:
            raise ImportError("The 'mapclassify' package is required")

    def p(n, N):
        """ Relative abundance """
        if n == 0:
            return 0
        return (float(n) / N) * ln(float(n) / N)

    if categorical:
        counts = data.value_counts().to_dict()
        for c in categories:
            if c not in counts.keys():
                counts[c] = 0
    else:
        sample_bins = mc.UserDefined(data, bins)
        counts = dict(zip(bins, sample_bins.counts))

    N = sum(counts.values())

    return -sum(p(n, N) for n in counts.values() if n != 0)

mapclassify

Classification Schemes for Choropleth Maps.

BSD-3-Clause
Latest version published 23 days ago

Package Health Score

81 / 100
Full package analysis

Similar packages