Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
E
Eo Toolbox Rtd
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Conditions générales et politique de confidentialité
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
ELIE
Eo Toolbox Rtd
Validations
cf575709
Valider
cf575709
rédigé
Il y a 9 mois
par
Boris Nörgaard
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
test2
parent
bc8e7c91
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
docs/build/html/notebooks/region_of_interest.ipynb
+1
-1
1 ajout, 1 suppression
docs/build/html/notebooks/region_of_interest.ipynb
avec
1 ajout
et
1 suppression
docs/build/html/notebooks/region_of_interest.ipynb
+
1
−
1
Voir le fichier @
cf575709
...
...
@@ -32,7 +32,7 @@
"print('All libraries successfully imported!')\n",
"print(f'GeoPandas : {gpd.__version__}')\n",
"\n",
"print('TEST')"
"print('TEST
2
')"
]
},
{
...
...
%% Cell type:markdown id: tags:
# Region of Interest
%% Cell type:code id: tags:
```
python
import
os
import
geopandas
as
gpd
from
shapely.geometry
import
Polygon
from
pathlib
import
Path
import
matplotlib.pyplot
as
plt
from
IPython.display
import
display
print
(
'
All libraries successfully imported!
'
)
print
(
f
'
GeoPandas :
{
gpd
.
__version__
}
'
)
print
(
'
TEST
'
)
print
(
'
TEST
2
'
)
```
%% Output
All libraries successfully imported!
GeoPandas : 0.9.0
%% Cell type:markdown id: tags:
## Set directory
%% Cell type:code id: tags:
```
python
computer_path
=
'
/export/miro/ndeffense/LBRAT2104/
'
#computer_path = 'H:/ndeffense/LBRAT2104/'
#computer_path = 'X:/'
grp_letter
=
'
X
'
# Directory for all work files
work_path
=
f
'
{
computer_path
}
GROUP_
{
grp_letter
}
/WORK/
'
# Directory where ROI shapefile is stored
roi_path
=
f
'
{
work_path
}
ROI/
'
# Create ROI path if not exists
Path
(
roi_path
).
mkdir
(
parents
=
True
,
exist_ok
=
True
)
```
%% Cell type:markdown id: tags:
## Choose CRS of your ROI
Choose the same CRS as the Sentinel data.
E.g. : WGS 84 / UTM zone 31N (EPSG:32631) if your ROI is located in Belgium
%% Cell type:code id: tags:
```
python
crs_dst
=
'
EPSG:32631
'
```
%% Cell type:markdown id: tags:
## Give a name for the ROI shapefile
Tip : You can include the EPSG code in the filename!
%% Cell type:code id: tags:
```
python
roi_name
=
'
extent_roi
'
roi_filename
=
f
'
{
roi_name
}
_
{
crs_dst
[
5
:
]
}
.shp
'
roi_file
=
f
'
{
roi_path
}{
roi_filename
}
'
print
(
f
'
ROI shapefile will be stored in :
{
roi_file
}
'
)
```
%% Output
ROI shapefile will be stored in : H:/ndeffense/LBRAT2104/GROUP_X/WORK/ROI/extent_roi_32631.shp
%% Cell type:markdown id: tags:
## Find the coordinates of your ROI bounding box (bbox)
To find the coordinates of a bounding box, check: http://bboxfinder.com/
**!! Be carefull of the crs_src you chose !!**
%% Cell type:code id: tags:
```
python
crs_src
=
'
EPSG:32631
'
bbox
=
[
627263.7
,
5590485.2
,
637115
,
5596175.1
]
ulx
=
bbox
[
0
]
uly
=
bbox
[
1
]
lrx
=
bbox
[
2
]
lry
=
bbox
[
3
]
print
(
f
'
Upper Left X :
{
ulx
}
'
)
print
(
f
'
Upper Left Y :
{
uly
}
'
)
print
(
f
'
Lower Right X :
{
lrx
}
'
)
print
(
f
'
Lower Right Y :
{
lry
}
'
)
```
%% Output
Upper Left X : 627263.7
Upper Left Y : 5590485.2
Lower Right X : 637115
Lower Right Y : 5596175.1
%% Cell type:markdown id: tags:
## Store your ROI into a GeoDataFrame
%% Cell type:code id: tags:
```
python
# Create a list with the longitude coordinates (x)
lon_point_list
=
[
ulx
,
lrx
,
lrx
,
ulx
,
ulx
]
# Create a list with the latitude coordinates (y)
lat_point_list
=
[
uly
,
uly
,
lry
,
lry
,
uly
]
# Create a polygon object from the two list (lon and lat)
polygon_geom
=
Polygon
(
zip
(
lon_point_list
,
lat_point_list
))
# Create a GeoDataFrame with the polygon object
gdf
=
gpd
.
GeoDataFrame
(
index
=
[
0
],
crs
=
crs_src
,
geometry
=
[
polygon_geom
])
# Reproject the GeoDataFrame to the destination CRS (needed only if you set your coordinates in WGS 84)
gdf
=
gdf
.
to_crs
(
crs_dst
)
display
(
gdf
)
# Check CRS of your polygon
print
(
f
'
ROI CRS :
{
gdf
.
crs
}
'
)
```
%% Output
ROI CRS : EPSG:32631
%% Cell type:markdown id: tags:
### Add a name
%% Cell type:code id: tags:
```
python
gdf
[
'
name
'
]
=
'
ROI_wallonia
'
display
(
gdf
)
```
%% Output
%% Cell type:markdown id: tags:
## Plot your ROI
Is it a nice rectangular polygon?
%% Cell type:code id: tags:
```
python
fig
,
ax
=
plt
.
subplots
(
1
,
1
)
gdf
.
boundary
.
plot
(
ax
=
ax
)
plt
.
box
(
False
)
```
%% Output
%% Cell type:markdown id: tags:
## Write GeoDataFrame in a shapefile if not exists
%% Cell type:code id: tags:
```
python
if
not
os
.
path
.
isfile
(
roi_file
):
gdf
.
to_file
(
filename
=
roi_file
,
driver
=
'
ESRI Shapefile
'
)
print
(
f
'
A new vector file is created :
{
roi_file
}
'
)
else
:
print
(
'
The ROI vector file already exists --> delete it or change the variable
"
roi_name
"
if you want to create a new one
'
)
```
%% Output
The ROI vector file already exists --> delete it or change the variable "roi_name" if you want to create a new one
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter