Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hunan_index_py
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lixiao
hunan_index_py
Commits
c7676a55
Commit
c7676a55
authored
Nov 04, 2024
by
lixiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dockerfile
parent
8c6f423f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
32 deletions
+52
-32
Dockerfile
Dockerfile
+18
-10
main.py
main.py
+25
-22
requirements.txt
requirements.txt
+9
-0
No files found.
Dockerfile
View file @
c7676a55
FROM
python:3.9-slim
FROM
osgeo/gdal:ubuntu-small-latest
# 设置工作目录
WORKDIR
/home/code
WORKDIR
/app
COPY
./ /home/code
# 安装依赖
ENV
DEBIAN_FRONTEND=noninteractive
COPY
requirements.txt .
RUN
pip
install
-r
requirements.txt
# 复制项目文件
COPY
. .
# 运行主程序
RUN
echo
"
${
TZ
}
"
>
/etc/timezone
\
CMD
["python", "main.py"]
ln
-sf
/usr/share/zoneinfo/Asia/Shanghai /etc/localtime
\
apt-get clean
&&
apt-get update
&&
apt-get
install
-y
wget unzip vim gcc g++ tzdata
\
python3.10
\
python3-pip
\
git
ENV
TZ=Asia/Shanghai
RUN
pip
install
--no-cache-dir
-r
requirements.txt
-i
https://mirrors.aliyun.com/pypi/simple/
CMD
["python3","app.py"]
main.py
View file @
c7676a55
...
@@ -93,10 +93,11 @@ def get_landsat_tif_name(input_config):
...
@@ -93,10 +93,11 @@ def get_landsat_tif_name(input_config):
print
(
output_path
)
print
(
output_path
)
return
output_path
return
output_path
def
visible_go
(
input_config
):
def
visible_go
(
input_config
):
#拼写输出tif路径
#拼写输出tif路径
if
input_config
[
'satellite'
]
==
'sen
it
nel2'
:
if
input_config
[
'satellite'
]
==
'sen
ti
nel2'
:
output_path
=
get_s2_tif_name
(
input_config
)
output_path
=
get_s2_tif_name
(
input_config
)
elif
input_config
[
'satellite'
]
==
'landsat'
:
elif
input_config
[
'satellite'
]
==
'landsat'
:
output_path
=
get_landsat_tif_name
(
input_config
)
output_path
=
get_landsat_tif_name
(
input_config
)
...
@@ -132,17 +133,15 @@ def visible_go(input_config):
...
@@ -132,17 +133,15 @@ def visible_go(input_config):
print
(
'去除破碎像元开始'
)
print
(
'去除破碎像元开始'
)
image_processor
.
sieve_filter
(
output_path
)
image_processor
.
sieve_filter
(
output_path
)
#写出json
#写出json
if
input_config
[
'satellite'
]
==
'sentinel2'
:
if
input_config
[
'satellite'
]
==
'sentinel2'
:
json_path
=
input_config
[
'input_path'
]
.
replace
(
'metadata.xml'
,
'tileInfo.json'
)
json_path
=
input_config
[
'input_path'
]
.
replace
(
'metadata.xml'
,
'tileInfo.json'
)
if
input_config
[
'satellite'
]
==
'landsat'
:
if
input_config
[
'satellite'
]
==
'landsat'
:
json_path
=
input_config
[
'input_path'
]
.
replace
(
'MTL.xml'
,
'SR_stac.json'
)
json_path
=
input_config
[
'input_path'
]
.
replace
(
'MTL.xml'
,
'SR_stac.json'
)
outjson_path
=
out_json
(
input_config
,
json_path
,
output_path
)
outjson_path
=
out_json
(
input_config
,
json_path
,
output_path
)
logger
.
info
(
msg
=
'logC": f"写出json完成,{outjson_path}", "logP": "100
%
'
)
logger
.
info
(
msg
=
'logC": f"写出json完成,{outjson_path}", "logP": "100
%
'
)
return
'success'
return
outjson_path
def
sar_go
(
input_config
):
def
sar_go
(
input_config
):
...
@@ -175,30 +174,34 @@ def sar_go(input_config):
...
@@ -175,30 +174,34 @@ def sar_go(input_config):
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
# input_config = {
input_config
=
{
# "index": "NDWI",
"index"
:
"NDVI"
,
# "satellite": "sentinel2",
"satellite"
:
"sentinel2"
,
# "input_path": r"D:\hunan\50RKQ_l2a\metadata.xml",
"input_path"
:
r"D:\hunan\50RKQ_l2a\metadata.xml"
,
# "output_path": r"D:\hunan\50RKQ_l2a\test2"
"output_path"
:
r"D:\hunan\50RKQ_l2a\test3_ndvi"
# }
# "input_path": r"D:\hunan\s2-l2a\tiles\49\R\EL\2023\6\4\0\metadata.xml",
# "output_path": r"D:\hunan\s2-l2a\tiles\49\R\EL\2023\6\4\0\water"
}
# input_config = {
# "index": "NDVI",
# "satellite": "landsat",
# "input_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\LC08_L2SP_122043_20231227_20240104_02_T1_MTL.xml",
# "output_path": r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\test1"
# }
input_config
=
{
input_config
=
{
"index"
:
"NDWI"
,
"index"
:
"NDWI"
,
"satellite"
:
"sentinel1"
,
"satellite"
:
"landsat"
,
# "input_path":r"D:\hunan\s1_20240116_aws\S1A_IW_GRDH_1SDV_20231031T103557_20231031T103622_051008_062673_CCD9\manifest.safe",
"input_path"
:
r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\LC08_L2SP_122043_20231227_20240104_02_T1_MTL.xml"
,
# "output_path": r"D:\hunan\s1_20240116_aws\S1A_IW_GRDH_1SDV_20231031T103557_20231031T103622_051008_062673_CCD9\test\test_water3_mask.tif"
"output_path"
:
r"D:\hunan\landsat_data\LC08_L2SP_122043_20231227_20240104_02_T1\test1_ndwi"
"input_path"
:
r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\manifest.safe"
,
# "output_path":r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\test\test2.tif"
"output_path"
:
r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\test\test7.tif"
}
}
# input_config = {
# "index": "NDWI",
# "satellite": "sentinel1",
# # "input_path":r"D:\hunan\s1_20240116_aws\S1A_IW_GRDH_1SDV_20231031T103557_20231031T103622_051008_062673_CCD9\manifest.safe",
# # "output_path": r"D:\hunan\s1_20240116_aws\S1A_IW_GRDH_1SDV_20231031T103557_20231031T103622_051008_062673_CCD9\test\test_water3_mask.tif"
# "input_path":r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\manifest.safe",
# # "output_path":r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\test\test2.tif"
# "output_path":r"D:\hunan\S1A_IW_GRDH_1SDV_20231014T102655_20231014T102720_050760_061DF1_1AE9.SAFE\test\test7.tif"
# }
if
input_config
[
"satellite"
]
in
visible_satellite
:
if
input_config
[
"satellite"
]
in
visible_satellite
:
result
=
visible_go
(
input_config
)
result
=
visible_go
(
input_config
)
elif
input_config
[
"satellite"
]
in
sar_satellite
:
elif
input_config
[
"satellite"
]
in
sar_satellite
:
...
...
requirements.txt
View file @
c7676a55
numpy
==1.26.4
scipy
scikit-image
pyproj
==3.4.1
rasterio
==1.3.6
flask
tqdm
requests
pyyaml
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment