Module SICAR.sicar

SICAR Class Module.

This module defines a class representing the Sicar system for managing environmental rural properties in Brazil.

Classes

Sicar: Class representing the Sicar system.

Classes

class Sicar (driver: Captcha = SICAR.drivers.tesseract.Tesseract, headers: Dict = None)

Class representing the Sicar system.

Sicar is a system for managing environmental rural properties in Brazil.

It inherits from the Url class to provide access to URLs related to the Sicar system.

Attributes

_driver : Captcha
The driver used for handling captchas. Default is Tesseract.

Initialize an instance of the Sicar class.

Parameters

driver (Captcha): The driver used for handling captchas. Default is Tesseract. headers (Dict): Additional headers for HTTP requests. Default is None.

Returns

None

Ancestors

Methods

def download_country(self, polygon: Polygon | str, folder: pathlib.Path | str = PosixPath('brazil'), tries: int = 25, debug: bool = False, chunk_size: int = 1024)

Download polygon for the entire country.

Parameters

polygon (Polygon | str): The polygon to download the files. It can be either a Polygon enum value or a string representing the polygon's. folder (Path | str, optional): The folder path where the downloaded files will be saved. Defaults to 'brazil'. tries (int, optional): The number of download attempts allowed per state. Defaults to 25. debug (bool, optional): Whether to enable debug mode with additional print statements. Defaults to False. chunk_size (int, optional): The size of each chunk to download. Defaults to 1024.

Returns

Dict
A dictionary containing the results of the download operation. The keys are the state abbreviations, and the values are dictionaries representing the results of downloading each state. Each state's dictionary follows the same structure as the result of the download_state method. If a download fails for a state the corresponding value will be False.
def download_state(self, state: State | str, polygon: Polygon | str, folder: pathlib.Path | str = PosixPath('temp'), tries: int = 25, debug: bool = False, chunk_size: int = 1024) ‑> pathlib.Path | bool

Download the polygon or other output format for the specified state.

Parameters

state (State | str): The state for which to download the files. It can be either a State enum value or a string representing the state's abbreviation. polygon (Polygon | str): The polygon to download the files. It can be either a Polygon enum value or a string representing the polygon's. folder (Path | str, optional): The folder path where the downloaded data will be saved. Defaults to "temp". tries (int, optional): The number of attempts to download the data. Defaults to 25. debug (bool, optional): Whether to print debug information. Defaults to False. chunk_size (int, optional): The size of each chunk to download. Defaults to 1024.

Returns

Path | bool: The path to the downloaded data if successful, or False if download fails.

Note

This method attempts to download the polygon for the specified state. It tries multiple times, using a captcha for verification. The downloaded data is saved to the specified folder. The method returns the path to the downloaded data if successful, or False if the download fails after the specified number of tries.