Commit 1b0f08eb authored by Guyot's avatar Guyot

Premier commit du tout

parent 473f8f54
This diff is collapsed.
''' Programme de placement de tags images sur un fond OpenStreetMap
On place des images géotaguées dans un répertoire
Le programme en extrait les coordonnées GPS et la date
Il crée des tags avec comme titre le nom des fichiers et la date
et les place sur le fond de carte aux coordonnées GPS
'''
#importation des module
import os(*@\label{ligne:lemoduleos}@*)
import folium(*@\label{ligne:modulefolium}@*)
import exifread(*@\label{ligne:exifread}@*)
def lalatitude(ref,GPSLatitude):
'''
Convertit les coordonnées GPS EXIF en degrés à virgule flottante
:param ref, GPSLongitude:
:type ref: string, GPSLongitude: exifread.utils.Ratio
:rtype: float
'''
d = GPSLatitude.values[0].num(*@\label{ligne:num1}@*)
m = GPSLatitude.values[1].num
s = GPSLatitude.values[2].num(*@\label{ligne:num2}@*)
if ref == 'N':
latitude = d + (m / 60.) + (s / 3600.)
elif ref == 'S':
latitude = -1*(d + (m / 60.0) + (s / 3600.0))
else:
print('La latitude est fausse !')
return latitude
def lalongitude(ref,GPSLongitude):
'''
Convertit les coordonnées GPS EXIF en degrés à virgule flottante
:param ref, GPSLongitude:
:type ref: string, GPSLongitude: exifread.utils.Ratio
:rtype: float
'''
d = GPSLongitude.values[0].num(*@\label{ligne:num3}@*)
m = GPSLongitude.values[1].num
s = GPSLongitude.values[2].num(*@\label{ligne:num4}@*)
if ref == 'W':
longitude = -1*(d + (m / 60.0) + (s / 3600.0))
elif ref == 'E':
longitude = d + (m / 60.0) + (s / 3600.0)
else:
print('La longitude est fausse !')
return longitude
# Récupération du facteur de zoom
print('Facteur de zoom (nombre entier) :\n\
9 : grande zone\n\
11 : zone\n\
13 : village ou ville\n\
16 : petite route')
facteurZoom = input('Veuillez entrer le facteur de zoom : ')(*@\label{ligne:input}@*)
print('Facteur de zoom : {}'.format(facteurZoom))
# Ouverture de l'image en mode de lecture binaire
path = './images/'
fichiers=os.listdir(path)(*@\label{ligne:listdir}@*)
i = 0 #indice des images(*@\label{ligne:compteurimages}@*)
for nom in fichiers:(*@\label{ligne:boucleprincipale}@*)
print("{} : {}".format(i,nom))
adresseImage = "./images/"+nom
titre = nom.split('.')[0]
f = open(adresseImage, 'rb')
# Récupération des tags EXIF
tags = exifread.process_file(f, details=False)
for tag in tags.keys():
if tag in ('GPS GPSLatitudeRef',
'GPS GPSLatitude',
'GPS GPSLongitudeRef',
'GPS GPSLongitude',
'Image ImageDateTime'):
latitude = lalatitude(tags['GPS GPSLatitudeRef'].values,
tags['GPS GPSLatitude'])
longitude = lalongitude(tags['GPS GPSLongitudeRef'].values,
tags['GPS GPSLongitude'])
date = tags['EXIF DateTimeOriginal']
try:(*@\label{ligne:try1}@*)
print("Latitude : {}, longitude : {}, date : {}".format(latitude,
longitude, date))(*@\label{ligne:try2}@*)
except NameError:(*@\label{ligne:except}@*)
print('Fichier sans données GPS : ',nom)
else:(*@\label{ligne:else}@*)
#création de l'objet Python carte, centrée sur les coordonnées
#latitude et longitude de la première image
if i == 0:
carte = folium.Map(location=[latitude, longitude],zoom_start=facteurZoom)(*@\label{ligne:carte}@*)
#création d'un marqueur
folium.Marker([latitude, longitude],(*@\label{ligne:markgoutte}@*)
popup="<h4>{}</h4> <br> <i>{}</i> <br><br> <img src='{}' width='300'"
.format(titre,date,adresseImage)).add_to(carte)(*@\label{ligne:gouttepopup}@*)
#création d'un simple cercle
folium.Circle(
radius=100,
location=[latitude, longitude],
popup='Gallet Park',(*@\label{ligne:cerclepopup}@*)
color='crimson',
fill=False,
).add_to(carte)
#création d'un marqueur en forme de cercle
folium.CircleMarker((*@\label{ligne:markcerclepopup}@*)
location=[latitude, longitude],
radius=50,
popup=titre,
color='#3186cc',
fill=True,
fill_color='#3186cc'
).add_to(carte)
#dereferencement des variables pour lever l'exception
del latitude, longitude(*@\label{ligne:deref}@*)
#changement d'image
i = i + 1
#création du fichier HTML
carte.save('ma_carte.html')(*@\label{ligne:sauvegarde}@*)
@Book{FA2019,
author = {Aït-Touati, Frédérique and Arènes, Alexandra and Grégoire, Axelle},
title = {Terra Forma, Manuel de cartographies potentielles},
publisher = {B42},
year = {2019},
month = {avril}
}
@Book{MM2019,
author = {Monmonier, Mark},
title = {Comment faire mentir les cartes},
publisher = {Atlas},
year = {2019},
month = {février},
note = {Édition revue et augmentée}
}
@Book{NL2017,
author = {Lambert, Nicolas and Zanin, Christine},
title = {Manuel de cartographie},
publisher = {Armand Colin},
year = {2017},
note = {Principes, méthodes, applications}
}
@Book{HC2014,
author = {Commenges, Hadrien and Beauguitte, Laurent and Buard, Elodie and Cura, Robin and Le Néchet, Florent and Le Texier, Marion and Mathian, Hélène and Rey, Sébastien},
title = {R et espace, Traitement de l'information géographique},
publisher = {Framabook},
year = {2014},
note = {Ouvrage libre publié sous licence CC By-SA 3.0}
}
@Book{BR86,
author = {Brunet, R},
title = {La carte-modèle et les chorèmes},
publisher = {Mappemonde},
year = {1986},
note = {86(4)}
}
@Book{BR87,
author = {Brunet, R},
title = {La carte mode d'emploi},
publisher = {Fayard/Reclus},
year = {1987},
note = {s.l.}
}
@Book{BR93,
author = {Brunet, R},
title = {Les mots de la géographie},
publisher = {Reclus - La Documentation française},
year = {1993},
note = {Montpellier/Paris}
}
@Book{DDF92,
author = {Durand-Dastès, F},
title = {Les modèles en géographie},
publisher = {Economica},
year = {1992},
note = {Paris}
}
@Book{HJB95,
author = {Harley, J. B.},
title = {Peut-il y avoir une éthique cartographique},
publisher = {s.n.},
year = {1995},
note = {Dans : Le pouvoir des cartes. sl}
}
@Book{LFA00,
author = {Le Fur, A.},
title = {Pratiques de la cartographie},
publisher = {Armad Colin},
year = {2000},
note = {Paris}
}
@Book{PD,
author = {Poidevin, D.},
title = {Manuel de cartographie},
publisher = {Ellipses},
year = {s.d.},
note = {s.l.}
}
@Book{FA2019,
author = {Aït-Touati, Frédérique and Arènes, Alexandra and Grégoire, Axelle},
title = {Terra Forma, Manuel de cartographies potentielles},
publisher = {B42},
year = {2019},
month = {avril}
}
@Book{MM2019,
author = {Monmonier, Mark},
title = {Comment faire mentir les cartes},
publisher = {Atlas},
year = {2019},
month = {février},
note = {Édition revue et augmentée}
}
@Book{NL2017,
author = {Lambert, Nicolas and Zanin, Christine},
title = {Manuel de cartographie},
publisher = {Armand Colin},
year = {2017},
note = {Principes, méthodes, applications}
}
@Book{HC2014,
author = {Commenges, Hadrien and Beauguitte, Laurent and Buard, Elodie and Cura, Robin and Le Néchet, Florent and Le Texier, Marion and Mathian, Hélène and Rey, Sébastien},
title = {R et espace, Traitement de l'information géographique},
publisher = {Framabook},
year = {2014},
note = {Ouvrage libre publié sous licence CC By-SA 3.0}
}
@Book{BRsd1,
author = {Brunet, R},
title = {La carte-modèle et les chorèmes},
publisher = {Mappemonde},
year = {sd},
note = {86(4)}
}
@Book{BRsd2,
author = {Brunet, R},
title = {Le monde des cartes},
publisher = {s.n.},
year = {sd},
note = {s.l.}
}
@Book{DDF92,
author = {Durand-Dastès, F},
title = {Les modèles en géographie},
publisher = {Economica},
year = {1992},
note = {Paris}
}
@Book{HJB95,
author = {Harley, J. B.},
title = {Peut-il y avoir une éthique cartographique},
publisher = {s.n.},
year = {1995},
note = {Dans : Le pouvoir des cartes. sl}
}
@Book{LFA00,
author = {Le Fur, A.},
title = {Pratiques de la cartographie},
publisher = {Armad Colin},
year = {2000},
note = {Paris}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
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