Commit a79a4793 authored by Poulard Christine's avatar Poulard Christine :snake:
Browse files

Replace AtelierD_Champs.py

parent fd1d7519
No related merge requests found
Showing with 9 additions and 7 deletions
+9 -7
...@@ -63,21 +63,22 @@ def lecture_shape(chemin, trace=False): ...@@ -63,21 +63,22 @@ def lecture_shape(chemin, trace=False):
# exemple de format GeoJSON{'type': 'LineString', 'coordinates': ((0.0, 0.0), (25.0, 10.0), (50.0, 50.0))} # exemple de format GeoJSON{'type': 'LineString', 'coordinates': ((0.0, 0.0), (25.0, 10.0), (50.0, 50.0))}
# https://gist.github.com/drmalex07/5a54fc4f1db06a66679e + alukach commented on 1 Aug 2017 # https://gist.github.com/drmalex07/5a54fc4f1db06a66679e + alukach commented on 1 Aug 2017
objet_shapely = shape(first)
# tracé vite fait si demandé # tracé vite fait si demandé
if trace: if trace:
fig, ax = plt.subplots(111) fig, ax = plt.subplots()
fig.suptitle(f"fichier shape de {os.path.splitext(os.path.basename(chemin))[0]} (\n on a cherché 1 élément)") fig.suptitle(f"fichier shape de {os.path.splitext(os.path.basename(chemin))[0]} (\n on a cherché 1 élément)")
fig.tight_layout(rect=[0, 0.03, 1, 0.90]) fig.tight_layout(rect=[0, 0.03, 1, 0.90])
ax = fig.add_subplot(111) x, y = objet_shapely.exterior.xy
x, y = shape(first).exterior.xy
ax.plot(x, y, color='darkblue', alpha=0.7, linewidth=1, solid_capstyle='round', zorder=3) ax.plot(x, y, color='darkblue', alpha=0.7, linewidth=1, solid_capstyle='round', zorder=3)
ax.set_xticks(rotation=45) ax.tick_params(axis='x', rotation=45)
ax.axis('equal') # repère orthonormé ax.axis('equal') # repère orthonormé
fig.show() fig.show()
# Convert to shapely Polygon # Convert to shapely Polygon
return shape(first) return objet_shapely
else: else:
print("Problème de lecture") print("Problème de lecture")
...@@ -133,11 +134,10 @@ def lecture_shape_plusieurs_elements(chemin_fichier_shape, trace=False): ...@@ -133,11 +134,10 @@ def lecture_shape_plusieurs_elements(chemin_fichier_shape, trace=False):
print("Problème, aucun objet génométrique n'a été détecté dans le fichier shape" ) print("Problème, aucun objet génométrique n'a été détecté dans le fichier shape" )
else: else:
if trace: if trace:
fig, ax = plt.subplots(111) fig, ax = plt.subplots()
fig.suptitle(f"fichier shape de {os.path.splitext(os.path.basename(chemin_fichier_shape))[0]}" ) fig.suptitle(f"fichier shape de {os.path.splitext(os.path.basename(chemin_fichier_shape))[0]}" )
fig.tight_layout(rect=[0, 0.03, 1, 0.90]) fig.tight_layout(rect=[0, 0.03, 1, 0.90])
ax = fig.add_subplot(111)
for x, y in liste_xy: for x, y in liste_xy:
ax.plot(x, y, color='darkblue', alpha=0.7, linewidth=1, solid_capstyle='round', zorder=3) ax.plot(x, y, color='darkblue', alpha=0.7, linewidth=1, solid_capstyle='round', zorder=3)
...@@ -573,6 +573,7 @@ class Champ: ...@@ -573,6 +573,7 @@ class Champ:
f"La matrice de valeurs est vide, problème de lecture ; pour info, {nb_informations} mots-clés sur 8 ont été trouvés") f"La matrice de valeurs est vide, problème de lecture ; pour info, {nb_informations} mots-clés sur 8 ont été trouvés")
def test_trace_matrice_valeurs(self): def test_trace_matrice_valeurs(self):
# tracer champ de valeur seul
#cax = plt.imshow(self.matrice_valeurs) #cax = plt.imshow(self.matrice_valeurs)
fig, (ax, ax_extent) = plt.subplots(ncols=2, nrows=1) fig, (ax, ax_extent) = plt.subplots(ncols=2, nrows=1)
fig.suptitle("D'une matrice à une carte de champ") fig.suptitle("D'une matrice à une carte de champ")
...@@ -670,6 +671,7 @@ class Champ: ...@@ -670,6 +671,7 @@ class Champ:
def ecrire_grid(self, nom_fichier=None): def ecrire_grid(self, nom_fichier=None):
""" """
todo : METHODE A READAPTER AU CODE POUR L'ATELIER
http://gsp.humboldt.edu/OLM/Courses/GSP_318/02_X_5_WritingGridASCII.html http://gsp.humboldt.edu/OLM/Courses/GSP_318/02_X_5_WritingGridASCII.html
Go into "Properties" for the layer, select the "Symbology" tab and select "Custom" for the "Stretch Type". When you click "OK" you should see the raster Go into "Properties" for the layer, select the "Symbology" tab and select "Custom" for the "Stretch Type". When you click "OK" you should see the raster
:param nom_fichier: :param nom_fichier:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment