Hello everyone! Last year, I and four of my friends were planning a trip to rent a camper and travel darts ... I forgot the darts and the map on the day of the trip. Even though it's the key to this trip ... My friend and I were really depressed. Our property is a camper, a wallet, a change of clothes, a PC ... that! PC Anjan! !! If you don't have one, you can create it by programming (python)! !! I created it, so I think I'll write an article.
・ Those who were trying to travel darts but forgot the important darts and have a computer at hand ・ Those who have a personal computer and do not have darts and a map of Japan
I thought that I had to have a map to travel darts, so I investigated how to output a map of Japan with python. Then I could use a library called folium, so I tried it.
nihon.py
import numpy as np
import pandas as pd
import folium
from folium import plugins
#Hakodate
LAT = 41.773709
LNG = 140.726413
map = folium.Map(location=[LAT,LNG])
#Make a pin
folium.Marker(
location=[LAT,LNG],
popup="This is Simple Marker"
).add_to(map)
#Run
map
The output looks like this!
Since I entered the latitude and longitude of Hakodate City, the output is solid!
If you randomize the longitude and latitude here and randomize the latitude and longitude of Japan, it will be completed! The code is here.
nihon.py
import numpy as np
import pandas as pd
import random
import folium
from folium import plugins
#Numbers are randomly assigned within the range of Japan.
LAT = random.uniform(20,46)
LNG = random.uniform(112,154)
map = folium.Map(location=[LAT,LNG])
#Make a pin
folium.Marker(
location=[LAT,LNG],
popup="This is Simple Marker"
).add_to(map)
#Run
map
Where should we go! python! You decide! e? ... Eh ...
This time, I used a library called folium to visualize the map and created a simple darts trip with the random function. I want to make it so that it will not fall into the sea, but I would like to rewrite it again when I have time. Then everyone ... are you ready for sea bread?
Recommended Posts