The SITS Module
The def_geobox function
- sits.def_geobox(bbox, crs_out=3035, resolution=10, shape=None)
This function creates an odc geobox.
- Parameters:
bbox (list) – coordinates of a bounding box in CRS units.
crs_out (str, optional) – CRS (EPSG code) of output coordinates. Defaults to 3035.
resolution (float, optional) – output spatial resolution in CRS units. Defaults to 10 (meters).
shape (tuple, optional) – output image size in pixels (x, y). Defaults to None.
- Returns:
geobox object
- Return type:
odc.geo.geobox.GeoBox
Example
>>> bbox = [100, 100, 200, 220] >>> crs_out = 3035 >>> # output geobox closest to the input bbox >>> geobox = def_geobox(bbox, crs_out)
>>> # output geobox with the same dimensions (number of rows and columns) >>> # as the input shape. >>> geobox = def_geobox(bbox, crs_out, shape=(10, 10))
The def_geobox function
The def_geobox function
- sits.sits.def_geobox(bbox, crs_out=3035, resolution=10, shape=None)
This function creates an odc geobox.
- Parameters:
bbox (list) – coordinates of a bounding box in CRS units.
crs_out (str, optional) – CRS (EPSG code) of output coordinates. Defaults to 3035.
resolution (float, optional) – output spatial resolution in CRS units. Defaults to 10 (meters).
shape (tuple, optional) – output image size in pixels (x, y). Defaults to None.
- Returns:
geobox object
- Return type:
odc.geo.geobox.GeoBox
Example
>>> bbox = [100, 100, 200, 220] >>> crs_out = 3035 >>> # output geobox closest to the input bbox >>> geobox = def_geobox(bbox, crs_out)
>>> # output geobox with the same dimensions (number of rows and columns) >>> # as the input shape. >>> geobox = def_geobox(bbox, crs_out, shape=(10, 10))
The Gdfgeom class
- class sits.Gdfgeom
Bases:
object
This class aims to calculate vector’s buffers and bounding box.
- buffer
vector layer with buffer.
- Type:
GeoDataFrame
- bbox
vector layer’s bounding box.
- Type:
GeoDataFrame
- set_bbox(df_attr)
Calculate the bounding box for each
Csv2gdf
’s GeoDataFrame feature.- Parameters:
df_attr (str) – GeoDataFrame attribute of class
Csv2gdf
. Can be one of the following: ‘gdf’, ‘buffer’, ‘bbox’.outfile (str, optional) – ouput filepath. Defaults to None.
- Returns:
GeoDataFrame object
Csv2gdf.bbox
.- Return type:
GeoDataFrame
Example
>>> geotable.set_bbox('buffer')
- set_buffer(df_attr, radius)
Calculate buffer geometries for each
Csv2gdf
’s GeoDataFrame feature.- Parameters:
df_attr (str) – GeoDataFrame attribute of class
Csv2gdf
. Can be one of the following: ‘gdf’, ‘buffer’, ‘bbox’.radius (float) – buffer distance in CRS unit.
outfile (str, optional) – ouput filepath. Defaults to None.
- Returns:
GeoDataFrame object
Csv2gdf.buffer
.- Return type:
GeoDataFrame
Example
>>> geotable.set_buffer('gdf', 100)
- to_vector(df_attr, outfile=None, driver='GeoJSON')
Write a
Csv2gdf
’s GeoDataFrame layer as a vector file.- Parameters:
df_attr (str) – GeoDataFrame attribute of class
Csv2gdf
. Can be one of the following: ‘gdf’, ‘buffer’, ‘bbox’.outfile (str, optional) – Output path. Defaults to None.
driver (str, optional) – Output vector file format (see GDAL/OGR Vector drivers: https://gdal.org/drivers/vector/index.html). Defaults to “GeoJSON”.
Example
>>> filename = 'mygeom' >>> geotable.to_vector('gdf', f'output/{filename}_gdf.geojson') >>> geotable.to_vector('buffer', f'output/{filename}_buffer.geojson') >>> geotable.to_vector('bbox', f'output/{filename}_bbox.geojson')