query module

class query.Query(config={}, args={})

Bases: object

Database query class

area(territory_types=['MUN'], id_territory=[], id_uf=[], id_mun=[], name_basin=[], verbose=False, **kwargs)

Return the total area of a given space definition

Parámetros
  • territory_types (list, optional) – Specify territory type. Available types: “TI”, “UCF”, “UCE”, “APAF”, “APAE”, “MUN”, “UF”. Buffers can be invoked using {type}_B[1-3] An empty list [] means no selection by territory type. Defaults to [ “MUN” ].

  • id_territory (list, optional) – Specify IDs of territory entitiess if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_uf (list, optional) – Specify IDs of UFs if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_mun (list, optional) – Specify IDs of municipalities if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • name_basin (str, optional) – Specify the name of a hydrographic basin if you want only results relative to this basin. Defaults to «» (no clippping entity filtering).

  • verbose (boolean, optional) – Output console messages. Defaults to False.

Tipo del valor devuelto

int

Devuelve

The total area for the selection False on error

basin(verbose=False)

Retrieve basin data from canonical basins_lvl2_ana.

Parámetros

verbose (boolean, optional) – Output console messages. Defaults to False.

Tipo del valor devuelto

list

Devuelve

List of basins. Currently restricts basins which are inside the Legal Amazon. False on error

close()
events(territory_types=['MUN'], event_type='deter', event_class=1, output_geometry_aggregated=False, output_geometry_disaggregated=False, centroid=False, by_timeperiod=True, temporal_unit='month', temporal_aggregation_on_interval_end=False, date_initial='2019-01-01', date_final='2021-01-01', id_territory=[], id_uf=[], id_mun=[], name_territory=[], name_uf=[], name_mun=[], name_basin=[], group_by=['mun'], compute_emissions=False, verbose=False, smart_area=False, bounds=[], geojson=False, json=False)

Return pressures/menaces events from a given space/time definition

Parámetros
  • territory_types (list, optional) – Specify territory type. Available types: “TI”, “UCF”, “UCE”, “APAF”, “APAE”, “MUN”, “UF”. Buffers can be invoked using {type}_B[1-3] for territory types “TI”, “UCF”, “UCE”, “APAF”, “APAE”. An empty list [] means no selection by territory type. Defaults to [ “MUN” ],

  • event_type (str, optional) – Type of alert event. Defaults to “deter”.

  • event_class (int, optional) – For “deter” events, classes are 1=Deforestation class, 2=Burning class, 3=Logging class. Defaults to 1.

  • output_geometry_aggregated (boolean, optional) – Whether the output should have geometry attributes. Defaults to False.

  • output_geometry_disaggregated (boolean, optional) – Whether the output should have geometry attributes, but without territory intersection. Defaults to False.

  • centroid (boolean, optional) – Whether to include centroid coordinates in the output. Defaults to False.

  • by_timeperiod (boolean, optional) – Whether the output should be aggregated on time units. Defaults to True.

  • temporal_unit (str, optional) – Unit of the temporal aggregation. Can be “Year”,”Quarter”, “Month”, “Week” or “Day”. Defaults to “Month”.

  • temporal_aggregation_on_interval_end (boolean, optional) – Whether the temporal desaggregation should be set to the end of the interval. If set to False, aggregation will default to the begining of the interval using PostgreSQL’s DATE_TRUNC(). If set to True, aggregated dates will be set to the end of the interval. Does not work for «prodes» events. Defaults to False.

  • date_initial (str, optional) – Initial analysis date (inclusive). Defaults to “2019-01-01”.

  • date_final (str, optional) – Final analysis date (exclusive). Defaults to “2021-01-01”.

  • id_territory (list, optional) – Specify IDs of territory entitiess if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_uf (list, optional) – Specify IDs of UFs if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_mun (list, optional) – Specify IDs of municipalities if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • name_territory (list, optional) – Specify names of territory entities if you want results relative to those units. Defaults to [] (no clippping entity filtering).

  • name_uf (list, optional) – Specify names of UFs if you want results relative to those administrative units. Defaults to [] (no clippping entity filtering).

  • name_mun (list, optional) – Specify names of Municipalities if you want results relative to those administrative units. Defaults to «» (no clippping entity filtering).

  • name_basin (str, optional) – Specify the name of a hydrographic basin if you want only results relative to this basin. Defaults to «» (no clippping entity filtering).

  • group_by (list, optional) – Specify which groupings (GROUP BY) should be used in the query. Available groupings: “territory”, “territory_type”, “uf”, “mun”, “basin”. Defaults to [ “territory”, “territory_type “].

  • compute_emissions (boolean, optional) – Whether the output should include the associated Carbon emissions. Defaults to False.

  • verbose (boolean, optional) – Output console messages. Defaults to False.

  • smart_area (boolean, optional) – Uses advanced method to compute total area. Have no effect for territory types without superpositions like “UF” and “MUN”. Defaults to False.

  • bounds (list, optional) – Restrict selection to the given bounding box. Format is [ southwest_lng, southwest_lat, northeast_lng, northeast_lat ] Defaults to an empty list (no bounding box restriction).

  • geojson (boolean, optional) – Whether to use GeoJSON in the geometry outputs. Defaults to False.

  • json (boolean, optional) – Whether to envelope the output with JSON. Defaults to False.

Tipo del valor devuelto

list

Devuelve

Events satisfying the given conditions or False on error

is_polygon(event_type)

Use a query to check if the geometry of requested events is of type Point

municipality(uf=[], verbose=False)

Retrieve municipality data from canonical Base 250 table.

Parámetros
  • uf (list, optional) – Restrict to the given Federal Unit state codes.

  • verbose (boolean, optional) – Output console messages. Defaults to False.

Tipo del valor devuelto

list

Devuelve

List of municipalities. Currently restricts municipalies which are inside the Legal Amazon. False on error

run_query(query, verbose=False)

Run a query, calculating elapsed time, handling errors, timeouts and other operational issues.

territories(territory_types=['MUN'], id_territory=[], id_uf=[], id_mun=[], name_basin=[], verbose=False, tile_x=0, tile_y=0, tile_z=0)

Return territory tiles from a given space definition

Parámetros
  • territory_types (list, optional) – Specify territory type. Available types: “TI”, “UCF”, “UCE”, “APAF”, “APAE”, “MUN”, “UF”. Buffers can be invoked using {type}_B[1-3] An empty list [] means no selection by territory type. Defaults to [ “MUN” ].

  • id_territory (list, optional) – Specify IDs of territory entitiess if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_uf (list, optional) – Specify IDs of UFs if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_mun (list, optional) – Specify IDs of municipalities if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • name_basin (str, optional) – Specify the name of a hydrographic basin if you want only results relative to this basin. Defaults to «» (no clippping entity filtering).

  • verbose (boolean, optional) – Output console messages. Defaults to False.

  • tile_x (int, optional) – Indicate the {x} coordinate for vector tiles output. Defaults to zero, no coordinate specified.

  • tile_y (int, optional) – Indicate the {y} coordinate for vector tiles output. Defaults to zero, no coordinate specified.

  • tile_z (int, optional) – Indicate the map zoom level {z} for vector tiles output. Defaults to zero, no coordinate specified.

Tipo del valor devuelto

bytes

Devuelve

Mapbox Vector Tiles False on error

tiles(territory_types=['MUN'], event_type='deter', event_class=1, date_initial='2019-01-01', date_final='2021-01-01', id_territory=[], id_uf=[], id_mun=[], name_territory=[], name_uf=[], name_mun=[], name_basin=[], verbose=False, tile_x=0, tile_y=0, tile_z=0)

Return pressures/menaces tiles from a given space/time definition

Parámetros
  • territory_types (list, optional) – Specify territory type. Available types: “TI”, “UCF”, “UCE”, “APAF”, “APAE”, “MUN”, “UF”. Buffers can be invoked using {type}_B[1-3] An empty list [] means no selection by territory type. Defaults to [ “MUN” ],

  • event_type (str, optional) – Type of alert event. Defaults to “deter”.

  • event_class (int, optional) – For “deter” events, classes are 1=Deforestation class, 2=Burning class, 3=Logging class. Defaults to 1.

  • date_initial (str, optional) – Initial analysis date (inclusive). Defaults to “2020-01-01”.

  • date_final (str, optional) – Final analysis date (exclusive).

  • id_territory (list, optional) – Specify IDs of territory entitiess if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_uf (list, optional) – Specify IDs of UFs if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

  • id_mun (list, optional) –

    Specify IDs of municipalities if you want only results relative to those units. Defaults to [] (no clippping entity filtering).

    Defaults to “2021-01-01”.

  • name_territory (list, optional) – Specify names of territory entities if you want results relative to those units. Defaults to [] (no clippping entity filtering).

  • name_uf (list, optional) – Specify names of UFs if you want results relative to those administrative units. Defaults to [] (no clippping entity filtering).

  • name_mun (list, optional) – Specify names of Municipalities if you want results relative to those administrative units. Defaults to «» (no clippping entity filtering).

  • name_basin (str, optional) – Specify the name of a hydrographic basin if you want only results relative to this basin. Defaults to «» (no clippping entity filtering).

  • verbose (boolean, optional) – Output console messages. Defaults to False.

  • tile_x (int, optional) – Indicate the {x} coordinate for vector tiles output. Defaults to zero, no coordinate specified.

  • tile_y (int, optional) – Indicate the {y} coordinate for vector tiles output. Defaults to zero, no coordinate specified.

  • tile_z (int, optional) – Indicate the map zoom level {z} for vector tiles output. Defaults to zero, no coordinate specified.

Tipo del valor devuelto

bytes

Devuelve

Mapbox Vector Tiles False on error

validate(params)

Validate common params.