Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ACT - Time Series Analysis in Flood-Prone Areas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Kies, Jacqueline
ACT - Time Series Analysis in Flood-Prone Areas
Commits
5535a75c
Commit
5535a75c
authored
2 years ago
by
Verouden, Niels
Browse files
Options
Downloads
Patches
Plain Diff
Update s21UrbanClipping.py
parent
fcd7a8f4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
urban_areas/py/s21UrbanClipping.py
+15
-5
15 additions, 5 deletions
urban_areas/py/s21UrbanClipping.py
with
15 additions
and
5 deletions
urban_areas/py/s21UrbanClipping.py
+
15
−
5
View file @
5535a75c
...
...
@@ -9,6 +9,7 @@ import pandas as pd
import
geopandas
as
gpd
import
rioxarray
as
rxr
import
geopandas
import
re
import
matplotlib.pyplot
as
plt
from
rasterio.mask
import
mask
from
rasterio
import
plot
...
...
@@ -52,7 +53,7 @@ def createBbox(coordinates, SAR_path, show_bbox='n'):
if
show_bbox
==
'
y
'
:
# Plot bbox and first SAR image
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
10
,
10
))
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
5
,
5
))
rio
.
plot
.
show
(
SAR
,
ax
=
ax
)
gdf
.
plot
(
ax
=
ax
,
facecolor
=
'
none
'
,
edgecolor
=
'
red
'
)
...
...
@@ -200,9 +201,9 @@ def clipSAR(SAR_path, urban_polygon_masked):
# # # Plot clipped SAR images
# fig, ax = plt.subplots(nrows=1, ncols=1, figsize=(15, 15))
# ax.imshow(SAR)
# ax.imshow(SAR
_clipped
)
# plt.axis('off')
# plt.title(tif[0:10], fontdict={'fontsize': 30})
# plt.title(
f'VV backscatter urban areas ({
tif[0:10]
})'
, fontdict={'fontsize': 30})
# plt.show()
return
list_of_means
,
list_of_dates
...
...
@@ -223,8 +224,17 @@ def exportToCSV(mean_values, dates, SAR_path):
df_mean_vv
=
pd
.
DataFrame
({
'
mean_VV
'
:
mean_values
,
'
date
'
:
dates
})
# Create name for csv file based on dates, and write dataframe to csv file
file_name
=
f
'
mean_VV_
{
SAR_path
}
_
{
dates
[
0
]
}
_
{
dates
[
-
1
]
}
.csv
'
count
=
SAR_path
.
count
(
'
/
'
)
if
count
!=
0
:
name
=
re
.
search
(
'
/(.+)
'
,
SAR_path
).
group
(
count
)
else
:
name
=
SAR_path
file_name
=
f
'
mean_VV_
{
name
}
_
{
dates
[
0
]
}
_
{
dates
[
-
1
]
}
.csv
'
path_mean_vv
=
os
.
path
.
join
(
'
data
'
,
'
mean_VV_csv
'
,
file_name
)
df_mean_vv
.
to_csv
(
path_mean_vv
,
encoding
=
'
utf-8
'
,
index
=
False
)
if
not
os
.
path
.
exists
(
path_mean_vv
):
df_mean_vv
.
to_csv
(
path_mean_vv
,
encoding
=
'
utf-8
'
,
index
=
False
)
else
:
print
(
f
"
\n
The following file already exists:
\n
{
file_name
}
"
)
return
file_name
,
path_mean_vv
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment