Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoSentinel
Project
Project
Details
Activity
Releases
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
Mario Chirinos Colunga
GeoSentinel
Commits
b2c048f0
Commit
b2c048f0
authored
Apr 20, 2018
by
Adan Salazar Garibay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding function selec_products and cleaning code
parent
b3180834
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
34 deletions
+33
-34
ui_utils.py
geosentinel/ui_utils.py
+33
-34
No files found.
geosentinel/ui_utils.py
View file @
b2c048f0
...
@@ -28,7 +28,8 @@ Functions:
...
@@ -28,7 +28,8 @@ Functions:
* "find_files" - Discover Sentinel files in directory
* "find_files" - Discover Sentinel files in directory
* "download_sentinel_mages" - Calibrate chessboard images discovered in a folder
* "download_sentinel_mages" - Calibrate chessboard images discovered in a folder
* "check_existing_directory" -
* "check_existing_directory" - Check out if the folder exist. Create folder if it does not exist
* "select_products" - # Select products that their intersection area is less than a certain percentage threshold
"""
"""
...
@@ -99,6 +100,33 @@ def check_existing_directory(folder) :
...
@@ -99,6 +100,33 @@ def check_existing_directory(folder) :
else
:
else
:
print
folder
+
" exists "
print
folder
+
" exists "
def
select_products
(
products_list
,
products_df
,
user_footprint
,
threshold
)
:
products_down
=
OrderedDict
()
products_down
=
products_list
.
copy
()
polyfootprint
=
ogr
.
CreateGeometryFromWkt
(
user_footprint
)
areafootprint
=
polyfootprint
.
GetArea
()
for
i
in
range
(
len
(
products_df
)):
inputpoly
=
ogr
.
CreateGeometryFromWkt
(
products_df
.
footprint
[
i
])
intersectionpoly
=
polyfootprint
.
Intersection
(
inputpoly
)
intersectionpoly_area
=
intersectionpoly
.
GetArea
()
por_intersection
=
(
intersectionpoly_area
*
100
)
/
areafootprint
if
(
por_intersection
<=
threshold
):
# Deleting element
del
products_down
[
products_df
.
uuid
[
i
]]
return
products_down
def
download_sentinel_mages
(
args
):
def
download_sentinel_mages
(
args
):
...
@@ -116,7 +144,7 @@ def download_sentinel_mages(args):
...
@@ -116,7 +144,7 @@ def download_sentinel_mages(args):
products
.
product_type
=
args
.
product_type
products
.
product_type
=
args
.
product_type
products
.
platform_name
=
args
.
platform
products
.
platform_name
=
args
.
plat
t
form
products
.
intersection_th
=
args
.
overlap
products
.
intersection_th
=
args
.
overlap
...
@@ -126,42 +154,13 @@ def download_sentinel_mages(args):
...
@@ -126,42 +154,13 @@ def download_sentinel_mages(args):
producttype
=
products
.
product_type
,
producttype
=
products
.
product_type
,
platformname
=
products
.
platform_name
)
platformname
=
products
.
platform_name
)
polyfootprint
=
ogr
.
CreateGeometryFromWkt
(
products
.
interest_footprint
)
areafootprint
=
polyfootprint
.
GetArea
()
# filtering products that their intersection is less than --intersection_th
products_down
=
OrderedDict
()
products_down
=
products_list
.
copy
()
# convert to pandas
products_df
=
api
.
to_dataframe
(
products_list
)
products_df
=
api
.
to_dataframe
(
products_list
)
counter
=
0
for
i
in
range
(
len
(
products_list
)):
inputpoly
=
ogr
.
CreateGeometryFromWkt
(
products_df
.
footprint
[
i
])
intersectionpoly
=
polyfootprint
.
Intersection
(
inputpoly
)
products_to_downloading
=
select_products
(
products_list
,
products_df
,
products
.
interest_footprint
,
products
.
intersection_th
)
intersectionpoly_area
=
intersectionpoly
.
GetArea
()
por_intersection
=
(
intersectionpoly_area
*
100
)
/
areafootprint
print
"area from elemet
%
:"
,
intersectionpoly_area
print
"Intersection zone
%
:"
,
por_intersection
if
(
por_intersection
<=
products
.
intersection_th
):
# Deleting element
del
products_down
[
products_df
.
uuid
[
i
]]
counter
=
counter
+
1
#print ("%d found elements that are not going to be downloaded" % counter)
#print ("Downloading %d elements ..." % len(products_down) )
os
.
chdir
(
args
.
output_folder
)
os
.
chdir
(
args
.
output_folder
)
api
.
download_all
(
products_
down
)
api
.
download_all
(
products_
to_downloading
)
...
...
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