flowmachine.features.spatial.location_area¶
Source: flowmachine/features/spatial/location_area.py
Methods for calculating area representations from a collection of infrastructure elements. These elements need to be point collections with geographic properties.
Class LocationArea¶
LocationArea(
point_collection="sites",
date=None,
method="voronois",
envelope_table="geography.admin0",
radius=35,
dem="elevation.nasa_srtm1",
band=1,
location_identifier="id",
geometry_identifier="geom_point",
above_ground_position=0,
)
Class for generating a location area. This class is designed for generating surface area representation for a given point collection. Areas can be circles (generated from a given radius), Voronoi polygons, or a combination of those. Other more advanced methods will be implemented in the future. This class implements the Viewshed algorithm as proposed by Franklin, W.R., C.K. Ray, and S. Mehta, 1994. "Geometric Algorithms for Siting of Air Defense Missile Batteries", Technical Report DAAL03-86-D-0001, Battelle, Columbus Division, Columbus, Ohio, 129 p.
Attributes¶
Parameters¶
-
point_collection
:list
,str
, default'sites'
A point collection with longitude and latitudes. This parameter can fetch a table in the database (if a str is passed) or a list collection of tuples.
-
location_identifier
:str
, default'id'
Location identifier from the point table to use. This identifier must be unique to each location.
-
geometry_identifier
:str
, default'geom_point'
Geometry column to use in computations. If calling a table from the database the column must have type
GEOMETRY
orGEOGRAPHY
. -
date
:str
, defaultNone
If using infrastructure.* tables (
sites
orcells
) then a date is needed to determine which version of locations to use (because infrastructure elements may change locations). If no date is provided, the current date is used. -
method
:str
, default'voronois'
Method to use to compute polygons. The method can be one of the following: * 'voronois': Computes a Voronoi tessellation. * 'radius-voronois': Calculates a Voronoi tessellation that is clipped based on a generated circle. * 'radius': Generates a circle based on a given input radius. * 'viewshed': Computes viewshed polygons from point collection. * 'radio-propagation': Computes radio propagation polygons from point collection (not implemented).
-
radius
:int
, default35
Radius of buffer area around circle to generate in Km. Default value is 35km.
-
envelope_table
:str
, default'geography.admin0'
Table to use for keeping all geometries within a certain envelope. This is generally used to keep generated polygons within the boundaries of a region or country. Default is
geography.admin0
. The table must contain a PostGISgeom
column. -
dem
:str
, default'elevation.nasa_srtm1'
Digital elevation model table. The default table is
nasa_srtm1
. -
band
:int
, default1
Band number identifier used to fetch data from the DEM. The default is
1
for this parameter, and rarely changes. -
above_ground_position
:float
,int
, default0
Position above ground in which the observer is placed. This position is used to place the observer above the elevation of its position. It is common that transmitters are placed on towers. This parameter indicates the height of the transmitters. It should match the unit of the DEM dataset provided in
dem
.
Methods¶
area¶
area(self)
Short-hand method for calculating the area of each LocationArea() representation computed. This method uses the projection from Flowdb (WGS84 by default). This could compute incorrect distances depending on the scenario.
Returns¶
-
DataFrame
pandas.DataFrame containing areas in Km.
cache¶
cache
Returns¶
-
bool
True is caching is switched on.
column_names¶
column_names
Returns the column names.
Returns¶
-
typing.List[str]
List of the column names of this query.
column_names_as_string_list¶
column_names_as_string_list
Get the column names as a comma separated list
Returns¶
-
str
Comma separated list of column names
dependencies¶
dependencies
Returns¶
-
set
The set of queries which this one is directly dependent on.
fully_qualified_table_name¶
fully_qualified_table_name
Returns a unique fully qualified name for the query to be stored as under the cache schema, based on a hash of the parameters, class, and subqueries.
Returns¶
-
str
String form of the table's fqn
index_cols¶
index_cols
A list of columns to use as indexes when storing this query.
Returns¶
-
ixen
:list
By default, returns the location columns if they are present and self.spatial_unit is defined, and the subscriber column.
Examples¶
daily_location("2016-01-01").index_cols
[['name'], '"subscriber"']
is_stored¶
is_stored
Returns¶
-
bool
True if the table is stored, and False otherwise.
query_id¶
query_id
Generate a uniquely identifying hash of this query, based on the parameters of it and the subqueries it is composed of.
Returns¶
-
str
query_id hash string
query_state¶
query_state
Return the current query state.
Returns¶
-
QueryState
The current query state
query_state_str¶
query_state_str
Return the current query state as a string
Returns¶
-
str
The current query state. The possible values are the ones defined in
flowmachine.core.query_state.QueryState
.
table_name¶
table_name
Returns a uniquename for the query to be stored as, based on a hash of the parameters, class, and subqueries.
Returns¶
-
str
String form of the table's fqn