How to use the regionmask.core.utils._maybe_to_dict function in regionmask

To help you get started, we’ve selected a few regionmask 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 mathause / regionmask / regionmask / core / regions.py View on Github external
r = Regions(outlines, numbers, names, abbrevs, name)

            # arguments are now optional
            r = Regions(outlines)

        """

        super(Regions, self).__init__()

        if numbers is None:
            numbers = range(len(outlines))

        if not _is_numeric(numbers):
            raise ValueError("'numbers' must be numeric")

        outlines = _maybe_to_dict(numbers, outlines)

        names = _sanitize_names_abbrevs(numbers, names, "Region")
        abbrevs = _sanitize_names_abbrevs(numbers, abbrevs, "r")

        regions = dict()

        for n in numbers:
            regions[n] = _OneRegion(n, names[n], abbrevs[n], outlines[n])

        self.regions = regions
        self.name = name
        self.source = source
github mathause / regionmask / regionmask / core / regions.py View on Github external
names=names,
            abbrevs=abbrevs,
            name=name,
            source=source,
        )

        if centroids is not None:
            msg = (
                "Specifying 'centroids' is deprecated and the keyword will be "
                "removed in the next version."
            )
            warnings.warn(msg, FutureWarning, stacklevel=3)

            numbers = self.numbers

            centroids = _maybe_to_dict(numbers, centroids)

            for number in numbers:
                self[number].centroid = centroids[number]