lmpy.data_preparation.build_grid
Module containing methods to build a shapegrid.
Module Contents
Functions
|
Build a shapegrid with an optional cutout. |
|
Generator producing hexagonal WKT for cells of the shapegrid. |
|
Create a polygon WKT string from a list of points. |
|
Generator producing square WKT for cells of the shapegrid. |
- lmpy.data_preparation.build_grid.build_shapegrid(shapegrid_file_name, min_x, min_y, max_x, max_y, cell_size, epsg_code, cell_sides, site_id='siteid', site_x='siteX', site_y='siteY', cutout_wkt=None)[source]
Build a shapegrid with an optional cutout.
- Parameters
shapegrid_file_name (str) – The location to store the resulting shapegrid.
min_x (numeric) – The minimum value for X of the shapegrid.
min_y (numeric) – The minimum value for Y of the shapegrid.
max_x (numeric) – The maximum value for X of the shapegrid.
max_y (numeric) – The maximum value for Y of the shapegrid.
cell_size (numeric) – The size of each cell (in units indicated by EPSG).
epsg_code (int) – The EPSG code for the new shapegrid.
cell_sides (int) – The number of sides for each cell of the shapegrid. 4 - square cells, 6 - hexagon cells
site_id (str) – The name of the site id field for the shapefile.
site_x (str) – The name of the X field for the shapefile.
site_y (str) – The name of the Y field for the shapefile.
cutout_wkt (None or str) – WKT for an area of the shapegrid to be cut out.
- Returns
The number of cells in the new shapegrid.
- Return type
int
- Raises
ValueError – Raised if invalid bbox or cell sides.
- lmpy.data_preparation.build_grid.hexagon_wkt_generator(min_x, min_y, max_x, max_y, x_res, y_res)[source]
Generator producing hexagonal WKT for cells of the shapegrid.
- Parameters
min_x (numeric) – The minimum x value.
min_y (numeric) – The minimum y value.
max_x (numeric) – The maximum x value.
max_y (numeric) – The maximum y value.
x_res (numeric) – The x size of the cell.
y_res (numeric) – The y size of the cell.
- Yields
str – Well-known text polygons for the cells.
- lmpy.data_preparation.build_grid.make_polygon_wkt_from_points(points)[source]
Create a polygon WKT string from a list of points.
- Parameters
points (list of tuple) – A list of (x,y) points for each vertex of the polygon.
Note
Points should be ordered following right hand rule.
- Returns
A polygon well-known text string.
- Return type
str
- lmpy.data_preparation.build_grid.square_wkt_generator(min_x, min_y, max_x, max_y, x_res, y_res)[source]
Generator producing square WKT for cells of the shapegrid.
- Parameters
min_x (numeric) – The minimum x value.
min_y (numeric) – The minimum y value.
max_x (numeric) – The maximum x value.
max_y (numeric) – The maximum y value.
x_res (numeric) – The x size of the cell.
y_res (numeric) – The y size of the cell.
- Yields
str – Well-known text polygons for the cells.