update
This commit is contained in:
parent
94580362be
commit
dd957f5cdb
28
lookup.py
28
lookup.py
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from geopy import Nominatim
|
from geopy import Nominatim
|
||||||
|
# ~ import json
|
||||||
|
|
||||||
geolocator = Nominatim(user_agent="my-mapper")
|
geolocator = Nominatim(user_agent="my-mapper")
|
||||||
|
|
||||||
|
@ -8,10 +9,25 @@ geolocator = Nominatim(user_agent="my-mapper")
|
||||||
|
|
||||||
fn="ct-csv"
|
fn="ct-csv"
|
||||||
with open( fn, 'r' ) as fp:
|
with open( fn, 'r' ) as fp:
|
||||||
for line in fp:
|
for place in fp:
|
||||||
location = geolocator.geocode(line)
|
#error handling: expect
|
||||||
# ~ print (location.latitude, location.longitude)
|
arrAddress = place.split(",")
|
||||||
|
strAddress = ",".join(arrAddress[1:4])
|
||||||
|
# ~ print( strAddress )
|
||||||
|
location = geolocator.geocode( strAddress )
|
||||||
if location is not None: # its a class
|
if location is not None: # its a class
|
||||||
# ~ print (location)
|
# todo: ceil coords to hide true location in format string
|
||||||
print ( location.latitude, location.longitude)
|
# ~ strCoordPlace = '{:s},{:.6f},{:.6f}'.format( arrAddress[3], location.latitude, location.longitude )
|
||||||
fp.close()
|
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
|
||||||
|
|
|
@ -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"
|
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
|
# preprocess csv data
|
||||||
for file in $(echo 'ct-csv\nerfa-csv'); do
|
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}
|
sed '1d' ${file} > tmpfile && mv tmpfile ${file}
|
||||||
done
|
done
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
pip3 install geopy # looking up addresses/coordinates
|
#~ pip3 install geopy # looking up addresses/coordinates
|
||||||
pip3 install folium # leaflet.js with python
|
#~ pip3 install folium # leaflet.js with python
|
||||||
|
|
Loading…
Reference in New Issue