This commit is contained in:
vv01f 2019-06-05 11:00:53 +02:00
parent 94580362be
commit dd957f5cdb
Signed by untrusted user who does not match committer: vv01f
GPG Key ID: 02625A16AC1D1FF6
2 changed files with 26 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from geopy import Nominatim
# ~ import json
geolocator = Nominatim(user_agent="my-mapper")
@ -8,10 +9,25 @@ geolocator = Nominatim(user_agent="my-mapper")
fn="ct-csv"
with open( fn, 'r' ) as fp:
for line in fp:
location = geolocator.geocode(line)
# ~ print (location.latitude, location.longitude)
for place in fp:
#error handling: expect
arrAddress = place.split(",")
strAddress = ",".join(arrAddress[1:4])
# ~ print( strAddress )
location = geolocator.geocode( strAddress )
if location is not None: # its a class
# ~ print (location)
print ( location.latitude, location.longitude)
fp.close()
# todo: ceil coords to hide true location in format string
# ~ strCoordPlace = '{:s},{:.6f},{:.6f}'.format( arrAddress[3], location.latitude, location.longitude )
geojson = '{{"type":"Feature","geometry": {{"type": "Point","coordinates":[{:.6f}, {:.6f}]}},"properties":{{"name":"{:s}","marker":"ct"}}}}';
strCoordPlace = geojson.format( location.latitude, location.longitude, arrAddress[3] )
# ~ {"type": "Feature","geometry": {"type": "Point","coordinates":[125.6, 10.1]},"properties":{"name":"Dinagat Islands"}}
print ( strCoordPlace )
# ~ m = folium.Map( # etc..)
# ~ m.save("filename.png")
# ~ https://github.com/python-visualization/folium/issues/35#issuecomment-164784086
# ~ https://github.com/wbkd/leaflet-mapshot
# ~ https://stackoverflow.com/questions/44800396/python-ipyleaflet-export-map-as-png-or-jpg-or-svg
# ~ m = folium.Map(location=[51, 13], zoom_start=5, tiles='Stamen Toner') # Mapbox Bright , CartoDB Positron

View File

@ -11,10 +11,11 @@ test -e ct-csv && echo "file already exists." || curl -o ct-csv "https://"${auth
test -e erfa-csv && echo "file already exists." || curl -o erfa-csv "https://"${auth}"doku.ccc.de/Spezial:Semantische_Suche/-5B-5BKategorie:Chaostreffs-5D-5D-20-5B-5BChaostreff-2DIs-2DErfa::wahr-5D-5D-20-5B-5BChaostreff-2DActive::wahr-5D-5D/-3FChaostreff-2DPhysical-2DAddress%3DAdresse/-3FChaostreff-2DPhysical-2DPostcode%3DPLZ/-3FChaostreff-2DPhysical-2DCity%3DStadt/-3FChaostreff-2DCountry%3DLand/mainlabel%3D/limit%3D100/order%3DASC/sort%3DErfa-2DCity/offset%3D0/format%3Dcsv/headers%3Dshow/searchlabel%3DCSV/sep%3D,/filename%3Derfa-2Dbesuchsadressen.csv"
# preprocess csv data
for file in $(echo 'ct-csv\nerfa-csv'); do
sed -e 's/"//g' -e 's/\([0-9]\{4,5\}\),/\1 /g' ${file} > tmpfile && mv tmpfile ${file}
sed -e 's/"//g' ${file} > tmpfile && mv tmpfile ${file}
#~ sed -e 's/\([0-9]\{4,5\}\),/\1 /g' ${file} > tmpfile && mv tmpfile ${file}
sed '1d' ${file} > tmpfile && mv tmpfile ${file}
done
# dependencies
pip3 install geopy # looking up addresses/coordinates
pip3 install folium # leaflet.js with python
#~ pip3 install geopy # looking up addresses/coordinates
#~ pip3 install folium # leaflet.js with python