-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
320 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
|
||
from pathlib import Path | ||
from consts import * | ||
from raster_ops.config_entity import * | ||
|
||
|
||
class ConfigManager: | ||
def __init__(self): | ||
pass | ||
|
||
def get_rasterdata_config(self): | ||
rasterdata_config = RasterdataConfig( | ||
raster_infile=RASTER_INPUT_FILE, | ||
polygon_infile=CLIP_BOUNDARY_FILE, | ||
clip_raster_file=CLIP_RASTER_OUTPUT_FILE, | ||
out_point_file=OUT_POINT_FILE, | ||
output_folder=RASTER_WORKING_DIR, | ||
lmax_list=BANDS_LMAX_VALUES, | ||
lmin_list=BANDS_LMIN_VALUES, | ||
qcal_min=QCAL_MIN_VALUE, | ||
qcal_max=QCAL_MAX_VALUE, | ||
prefix=OUT_NAME_PREFIX, | ||
lulc_raster_file=LULC_RASTER_FILE, | ||
lulc_out_raster_file=LULC_OUT_CLASS_FILE, | ||
lilc_class_code=LULC_CLASS_CODE | ||
) | ||
return rasterdata_config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from pathlib import Path | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass(frozen=True) | ||
class RasterdataConfig: | ||
raster_infile: Path | ||
polygon_infile: Path | ||
clip_raster_file: Path | ||
out_point_file: Path | ||
output_folder: Path | ||
lmax_list: list | ||
lmin_list: list | ||
qcal_min: float | ||
qcal_max: float | ||
prefix: str | ||
lulc_raster_file: Path | ||
lulc_out_raster_file: Path | ||
lilc_class_code: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from osgeo import gdal | ||
from logger import logger | ||
from raster_ops.config import ConfigManager | ||
from raster_ops.components.clip_raster import ClipRaster | ||
from utils import write_geotiff_file, np2gdal_dtype | ||
|
||
|
||
STAGE_NAME = "Clip raster by clip boundary extent" | ||
|
||
|
||
class ClipRasterPipeline: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def main(self): | ||
config = ConfigManager() | ||
rstconfig = config.get_rasterdata_config() | ||
obj = ClipRaster(rstconfig=rstconfig) | ||
clip = obj.subset_by_extent() | ||
# save raster | ||
ds = gdal.Open(rstconfig.raster_infile, gdal.GA_ReadOnly) | ||
src_geotransform = ds.GetGeoTransform() | ||
src_projection = ds.GetProjectionRef() | ||
ds = None | ||
write_geotiff_file( | ||
clip, | ||
gt=src_geotransform, | ||
sr=src_projection, | ||
outfile_path=rstconfig.clip_raster_file, | ||
dtype=np2gdal_dtype(str(clip.dtype)) | ||
) | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
logger.info(f">>>>> {STAGE_NAME} started <<<<<") | ||
obj = ClipRasterPipeline() | ||
obj.main() | ||
logger.info(f">>>>> {STAGE_NAME} completed <<<<<\n") | ||
except Exception as e: | ||
logger.exception(e) | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from logger import logger | ||
from raster_ops.config import ConfigManager | ||
from raster_ops.components.dn_to_radiance import dn_to_radiance | ||
|
||
|
||
STAGE_NAME = "Convert DN to Radiance of Satellite image bands" | ||
|
||
|
||
class DNToRadiancePipeline: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def main(self): | ||
config = ConfigManager() | ||
rstconfig = config.get_rasterdata_config() | ||
dn_to_radiance( | ||
rstconfig.raster_infile, | ||
rstconfig.output_folder, | ||
rstconfig.lmax_list, | ||
rstconfig.lmin_list, | ||
rstconfig.qcal_min, | ||
rstconfig.qcal_max, | ||
prefix=rstconfig.prefix | ||
) | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
logger.info(f">>>>> {STAGE_NAME} started <<<<<") | ||
obj = DNToRadiancePipeline() | ||
obj.main() | ||
logger.info(f">>>>> {STAGE_NAME} completed <<<<<\n") | ||
except Exception as e: | ||
logger.exception(e) | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from logger import logger | ||
from raster_ops.config import ConfigManager | ||
from raster_ops.components.export_land_class import extract_lulc_class | ||
|
||
|
||
STAGE_NAME = "Export LULC individual class" | ||
|
||
|
||
class ExportLULCClassPipeline: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def main(self): | ||
config = ConfigManager() | ||
rstconfig = config.get_rasterdata_config() | ||
extract_lulc_class( | ||
rstconfig.lulc_raster_file, | ||
rstconfig.lulc_out_raster_file, | ||
class_number=rstconfig.lilc_class_code | ||
) | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
logger.info(f">>>>> {STAGE_NAME} started <<<<<") | ||
obj = ExportLULCClassPipeline() | ||
obj.main() | ||
logger.info(f">>>>> {STAGE_NAME} completed <<<<<\n") | ||
except Exception as e: | ||
logger.exception(e) | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from logger import logger | ||
from raster_ops.components.convert_raster_to_point import raster_to_point | ||
from raster_ops.config import ConfigManager | ||
|
||
|
||
STAGE_NAME = "Convert gray-scale raster to point shapefile" | ||
|
||
|
||
class RasterToPointPipeline: | ||
def __init__(self) -> None: | ||
pass | ||
|
||
def main(self): | ||
config = ConfigManager() | ||
rstconfig = config.get_rasterdata_config() | ||
raster_to_point( | ||
rstconfig.raster_infile, | ||
rstconfig.out_point_file | ||
) | ||
return | ||
|
||
|
||
if __name__ == "__main__": | ||
try: | ||
logger.info(f">>>>> {STAGE_NAME} started <<<<<") | ||
obj = RasterToPointPipeline() | ||
obj.main() | ||
logger.info(f">>>>> {STAGE_NAME} completed <<<<<\n") | ||
except Exception as e: | ||
logger.exception(e) | ||
raise e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.