Пример #1
0
    def __init__(self, dataset, url, data, lccs):
        """Initialize instance with dictionary data.

        :param data: Dict with class system metadata.
        """
        super(Dataset, self).__init__(data or {})
        #: Dataset: The associated Dataset.
        self._dataset = dataset
        self.metadata_json = self.prepare_metadata()
        self.__url = url
        self.__lccs_server = LCCS(lccs)
Пример #2
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Get a specific classification system
# Make sure the classification system is available in service
classification_system = service.classification_system('PRODES-1.0')

# Return the metadata of a specific class
class_metadata = classification_system.get_class('Desflorestamento')
print(class_metadata)

# You can access specific attributes
print(class_metadata.id)
print(class_metadata.name)
print(class_metadata.description)
print(class_metadata.code)
Пример #3
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Get a specific classification system
# Make sure the classification system is available in service
classification_system = service.classification_system(
    system_id='TerraClass_AMZ')

# Return the metadata of a specific class
class_metadata = classification_system.classes(class_id='Desflorestamento')
print(class_metadata)

# You can access specific attributes
print(class_metadata.id)
print(class_metadata.name)
print(class_metadata.description)
print(class_metadata.code)
Пример #4
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Save Style File
service.get_styles(system_id='MapBiomas5', format_id='QGIS')

# Save Style File passing the path directory
service.get_styles(system_id='MapBiomas5', format_id='QGIS', path='/home/user/Downloads/')
Пример #5
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/")

# Return the list of available clasification system for mapping
available_mappings = service.available_mappings('PRODES-1.0')

print(available_mappings)
Пример #6
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("https://brazildatacube.dpi.inpe.br/dev/lccs/")

# Save Style File
service.get_style(system_name='PRODES-1.0', format_name='QGIS')

# Save Style File passing the path directory
service.get_style(system_name='PRODES-1.0',
                  format_name='QGIS',
                  path='/home/user/Downloads/')
Пример #7
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/")

# Get all styles available for a specific classification system
styles = service.style_formats('PRODES-1.0')

print(styles)
Пример #8
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Get all styles available for a specific classification system
styles = service.styles(system_id='MapBiomas5')

print(styles)
Пример #9
0
class Dataset(dict):
    """DataSet Class."""
    def __init__(self, dataset, url, data, lccs):
        """Initialize instance with dictionary data.

        :param data: Dict with class system metadata.
        """
        super(Dataset, self).__init__(data or {})
        #: Dataset: The associated Dataset.
        self._dataset = dataset
        self.metadata_json = self.prepare_metadata()
        self.__url = url
        self.__lccs_server = LCCS(lccs)

    def prepare_metadata(self) -> Union[None, DSMetada]:
        """Prepare dataset metadata."""
        if isinstance(self['metadata_json'], dict):
            metadata_json = DSMetada(self['metadata_json'])
            return metadata_json
        else:
            return None

    @property
    def id(self) -> str:
        """Return the dataset id."""
        return self['id']

    @property
    def classification_system_name(self) -> str:
        """Return the dataset classification system id."""
        return self['classification_system_name']

    @property
    def classification_system_id(self) -> str:
        """Return the dataset classification system name."""
        return self['classification_system_id']

    @property
    def classification_system_version(self) -> str:
        """Return the dataset classification system version."""
        return self['classification_system_version']

    def _get_classification_system(self) -> ClassificationSystem:
        """Return the classification system object."""
        system_id = f"{self['classification_system_name']}-{self['classification_system_version']}"
        return self.__lccs_server.classification_system(system_id)

    @property
    def classification_system(self) -> ClassificationSystem:
        """Return the classification system object."""
        return self._get_classification_system()

    @property
    def collect_method(self) -> str:
        """Return the dataset collect method name."""
        return self['collect_method_name']

    @property
    def collect_method_id(self) -> str:
        """Return the dataset collect method id."""
        return self['collect_method_id']

    @property
    def description(self) -> str:
        """Return the dataset description."""
        return self['description']

    @property
    def end_date(self) -> str:
        """Return the dataset end date."""
        return self['end_date']

    @property
    def start_date(self) -> str:
        """Return the dataset start date."""
        return self['start_date']

    @property
    def name(self) -> str:
        """Return the dataset name."""
        return self['name']

    @property
    def title(self) -> str:
        """Return the dataset identifier."""
        return self['title']

    @property
    def is_public(self) -> str:
        """Return the dataset is_public."""
        return self['is_public']

    @property
    def version(self) -> str:
        """Return the dataset version."""
        return self['version']

    @property
    def version_successor(self) -> Union[int, None]:
        """Return the dataset version_successor."""
        return self['version_successor']

    @property
    def version_predecessor(self) -> Union[int, None]:
        """Return the dataset version_predecessor."""
        return self['version_predecessor']

    @property
    def metadata(self) -> Union[DSMetada, None]:
        """Return the dataset metadata."""
        return self.metadata_json

    @property
    def dataset_table_id(self) -> int:
        """Return the dataset table name."""
        return self['dataset_table_id']

    @property
    def user_id(self):
        """Return the dataset user id (user id who performed the insertion of the dataset)."""
        return self['user_id']

    @property
    def created_at(self):
        """Return the dataset created_at date."""
        return self['created_at']

    @property
    def updated_at(self):
        """Return the dataset updated_at date."""
        return self['updated_at']

    @property
    def number_of_features(self):
        """Return the dataset updated_at date."""
        return self['number_of_features']

    def data(self,
             data_id: int = None,
             filter: dict = dict()) -> gpd.GeoDataFrame:
        """Return the dataset observation dataframe."""
        url = f'{self._dataset._url}/datasets/data'

        filter["access_token"] = self._dataset._access_token
        filter["dataset_id"] = self.id

        if data_id:
            filter["data_id"] = data_id
        else:
            if 'limit' not in filter or filter["limit"] is None:
                filter["limit"] = self.number_of_features

        features = Utils._get(url=url, **filter)
        return gpd.GeoDataFrame.from_features(features["features"])

    def _repr_html_(self):
        """HTML repr."""
        return Utils.render_html('dataset.html', dataset=self)
Пример #10
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/")

# Returns the list of classification system available on the service
print(service.classification_systems)
Пример #11
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Returns the mapping between two classification systems.
# Make sure the classification system is available in service
mappings = service.mappings(system_id_source='TerraClass_AMZ',
                            system_id_target='PRODES')

for mp in mappings.mapping:
    print("Source Class: {} ID: {} | Target Class: {} ID: {}".format(
        mp.source_class, mp.source_class_id, mp.target_class,
        mp.target_class_id))
Пример #12
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("https://brazildatacube.dpi.inpe.br/lccs/")

# Returns the mapping between two classification systems.
# Make sure the classification system is available in service
mapping = service.mappings(system_name_source='PRODES-1.0', system_name_target='TerraClass_AMZ-1.0')

print(mapping)
Пример #13
0
#
# This file is part of Python Client Library for the LCCS-WS.
# Copyright (C) 2020 INPE.
#
# Python Client Library for the LCCS-WS is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
#
"""LCCS Python Client examples."""

from lccs import LCCS

# Change to the LCCS-WS URL you want to use.
service = LCCS("http://brazildatacube.dpi.inpe.br/dev/lccs/")

# Return the list of available clasification system for mapping
available_mappings = service.available_mappings(
    system_id_source='TerraClass_AMZ')

print(available_mappings)