Last active
November 10, 2015 21:25
-
-
Save eric-pommereau/1d45d85014224eafe008 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################################################################################### | |
# Exemple d'utilisation du reverse geocodage sur la BAN | |
# D'une série de coordonnées géo (en csv) on récupère les adresses (les plus proches) | |
# Accès : http://api-adresse.data.gouv.fr/reverse/csv/ | |
###################################################################################### | |
# Soit le fichier de base lat pour latitude (y) lon pour longitude (x) | |
lat;lon | |
48.18962;-2.53815 | |
47.99303;-0.81681 | |
47.16353;0.42983 | |
48.86449;2.34176 | |
# pour l'exemple on installe httpie (lib python) --> pip install httpie | |
# Utiliser httpie pour interroger l'api BAN (le chemin du fichier soit être absolu) | |
[eric@Downloads]$ http --timeout 600 -f POST http://api-adresse.data.gouv.fr/reverse/csv/ data@/cheminAbsoluVersMonFichier/test.csv | |
#La réponse --------------------------------------- | |
HTTP/1.1 200 OK | |
Access-Control-Allow-Headers: X-Requested-With | |
Access-Control-Allow-Origin: * | |
Connection: keep-alive | |
Content-Disposition: attachment; filename="test.geocoded.csv" | |
Content-Length: 946 | |
Content-Type: text/csv; charset=utf-8 | |
Date: Mon, 09 Nov 2015 21:50:49 GMT | |
Server: nginx/1.2.1 | |
lat,lon,result_latitude,result_longitude,result_label,result_distance,result_type,result_id,result_housenumber,result_name,result_street,result_postcode,result_city,result_context,result_citycode | |
48.18962,-2.53815,48.18896,-2.538898,"5328 Les Rues Dolo, LE COMMUN 22230 Laurenan",91,housenumber,22122_C398B415_e1bfb4,5328,"Les Rues Dolo, LE COMMUN",,22230,Laurenan,"22, Côtes-d'Armor, Bretagne",22122 | |
47.99303,-0.81681,47.994205,-0.816853,5143 La Goupillère 53970 Montigné-le-Brillant,130,housenumber,53157_B055_f67bfa,5143,La Goupillère,,53970,Montigné-le-Brillant,"53, Mayenne, Pays de la Loire",53157 | |
47.16353,0.42983,47.164671,0.426634,9 La Lande 37220 Panzoult,272,housenumber,37178_B094_3e1bac,9,La Lande,,37220,Panzoult,"37, Indre-et-Loire, Centre Val-de-Loire",37178 | |
48.86449,2.34176,48.864274,2.341588,32 Rue Coquillière 75001 Paris,27,housenumber,75101_2318_04401e,32,Rue Coquillière,,75001,Paris,"75, Île-de-France",75101 | |
# la même avec CURL (-i pour voir les headers) | |
curl --form "data=@/Users/ericpommereau/Downloads/test.csv" http://api-adresse.data.gouv.fr/reverse/csv/ |
Et hop... :)
curl --form "data=@/Users/ericpommereau/Downloads/test.csv" http://api-adresse.data.gouv.fr/reverse/csv/
Génial.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
J'essaye de le porter en curl, une idée pourquoi
me retourne