src.utils_flask_sqla_geo.utilsgeometry
Module Contents
Classes
Abstract class to provide functions to create geofiles with Fiona |
|
Service to create gpkg from sqlalchemy models |
|
Service to create shapefiles from sqlalchemy models |
Functions
|
Export data in shape files (separated bu geometry type) |
|
Export data in gpkg file |
|
Generic export data |
|
Convert a geojson 3d in 2d |
|
Attributes
- class src.utils_flask_sqla_geo.utilsgeometry.FionaService[source]
Bases:
abc.ABC
Abstract class to provide functions to create geofiles with Fiona Class who inherite of this class must implement the following abstract methods: - create_fiona_struct - create_features_generic - save-files - close-files
- classmethod create_fiona_properties(db_cols, srid, dir_path, file_name, col_mapping=None)[source]
Create three shapefiles (point, line, polygon) with the attributes give by db_cols Parameters:
db_cols (list): columns from a SQLA model (model.__mapper__.c) srid (int): epsg code dir_path (str): directory path file_name (str): file of the shapefiles col_mapping (dict): mapping between SQLA class
attributes and “beatifiul” columns name
- Returns:
void
- classmethod create_features_generic(view, data, geom_col, geojson_col=None)[source]
Create the features of the shapefiles by serializing the datas from a GenericTable (non mapped table)
- Parameters:
view (GenericTable): the GenericTable object data (list): Array of SQLA model geom_col (str): name of the WKB geometry column of the SQLA Model geojson_col (str): name of the geojson column if present. If None create the geojson from geom_col with shapely
for performance reason its better to use geojson_col rather than geom_col
- Returns:
void
- classmethod build_feature(view, data, geo_colname, is_geojson)[source]
Fonction qui créer une feature au sens de fiona
- Parameters:
view (GenericTable): the GenericTable object is_geojson (boolean): la geometrie est elle sous forme de geojson data (Model) : SQLA model geo_colname (string) : nom de la colonne contenant le geom
- classmethod create_feature(data, geom, is_geojson=False)[source]
Create and write feature (a record of the file) for WKB data by serializing an SQLAlchemy object
- Parameters:
data (dict): the SQLAlchemy model serialized as a dict geom (WKB): the geom as WKB
- Returns:
void
- class src.utils_flask_sqla_geo.utilsgeometry.FionaGpkgService[source]
Bases:
FionaService
Service to create gpkg from sqlalchemy models
How to use: FionaShapeService.create_shapes_struct(**args) FionaShapeService.create_features(**args) FionaShapeService.save_and_zip_shapefiles()
- classmethod write_a_feature(feature, geom_wkt)[source]
write a feature by checking the type of the shape given
- class src.utils_flask_sqla_geo.utilsgeometry.FionaShapeService[source]
Bases:
FionaService
Service to create shapefiles from sqlalchemy models
How to use: FionaShapeService.create_fiona_struct(**args) FionaShapeService.create_features(**args) FionaShapeService.save_files()
- classmethod create_fiona_struct(db_cols, srid, dir_path, file_name, col_mapping=None, encoding='utf-8')[source]
Create three shapefiles (point, line, polygon) with the attributes give by db_cols Parameters:
db_cols (list): columns from a SQLA model (model.__mapper__.c) srid (int): epsg code dir_path (str): directory path file_name (str): file of the shapefiles col_mapping (dict): mapping between SQLA class attributes and “beatifiul” columns name encoding (str): define encoding of data to store in Shape. Default: utf-8.
- Returns:
void
- classmethod write_a_feature(feature, geom_wkt)[source]
write a feature by checking the type of the shape given
- src.utils_flask_sqla_geo.utilsgeometry.create_shapes_generic(view, srid, db_cols, data, dir_path, file_name, geom_col, geojson_col)[source]
Export data in shape files (separated bu geometry type) Parameters:
srid (int): epsg code db_cols (list): columns from a SQLA model (model.__mapper__.c) data (list): Array of SQLA model dir_path (str): directory path file_name (str): file of the shapefiles geom_col (str): name of the WKB geometry column of the SQLA Model geojson_col (str): name of the geojson column if present. If None create the geojson from geom_col with shapely
for performance reason its better to use geojson_col rather than geom_col
- src.utils_flask_sqla_geo.utilsgeometry.create_gpkg_generic(view, srid, db_cols, data, dir_path, file_name, geom_col, geojson_col)[source]
Export data in gpkg file Parameters:
srid (int): epsg code db_cols (list): columns from a SQLA model (model.__mapper__.c) data (list): Array of SQLA model dir_path (str): directory path file_name (str): file of the shapefiles geom_col (str): name of the WKB geometry column of the SQLA Model geojson_col (str): name of the geojson column if present. If None create the geojson from geom_col with shapely
for performance reason its better to use geojson_col rather than geom_col
- src.utils_flask_sqla_geo.utilsgeometry.export_geodata_as_file(view, srid, db_cols, data, dir_path, file_name, geom_col, geojson_col, export_format='gpkg')[source]
Generic export data Parameters:
srid (int): epsg code db_cols (list): columns from a SQLA model (model.__mapper__.c) data (list): Array of SQLA model dir_path (str): directory path file_name (str): file of the shapefiles geom_col (str): name of the WKB geometry column of the SQLA Model geojson_col (str): name of the geojson column if present. If None create the geojson from geom_col with shapely
for performance reason its better to use geojson_col rather than geom_col
export_format (str) : name of the exported format