Japanese football players in foreign clubs shown on the map.
Currently, the trend of Villarreal Kubo is being talked about, but I tried to visualize where the players who are active overseas are in Python/Folium. I would like to explain the points that I devised in that.
The custom icon used folium.features.CustomIcon. There wasn't much explanation in Japanese, and I managed to do it by relying on Explanation of Folium's site in English.
The team icons are collected on the net, the background is transparent and png, and they are put in the image folder, and the error handling when the icon is not found is also included in the following code.
Displaying information with this mouse over is called a tooltip in English. When you specify the Folium marker tooltip ='string' Just specify with. Please refer to the code below.
First of all, based on the information on Wikipedia, the longitude / latitude, icons, etc. of the home town and home stadium are collected and made into Excel. I really wanted to do it automatically by scraping, but since there aren't many, I decided to do it manually. .. .. The collected data of each player/team is saved in EXCEL and plotted from Pandas/Dataframe.
Excel data is used only in this light blue column
It was difficult to collect data as it was. Sweat
import pandas as pd import folium from glob import glob df_player= pd.read_excel ('PlayerClubData.xlsx', header=0,encoding='utf-8' ) m = folium.Map(location=[46, -1.5], zoom_start=4) for club in df_player['club'].unique(): df2=df_player[df_player['club']==club] #If there are two or more people, combine the names names=' '.join(df2['Player'].tolist()) # Series = > List =>join and str for item in df2.head(1).iterrows(): #It's a little confusing, but since only the first person in each club is plotted, head(1) if item['lat']>0 or item['lat']<0 : #Longitude data is float and nan is skipped l_in = [s for s in glob("./images/*.png ") if club in s] #Check for icon files if len(l_in)>0: #Number of applicable files: Usually 1 iconTmp = folium.features.CustomIcon(l_in, icon_size=(50,50)) #Specify the icon file here else: iconTmp=folium.Icon(color='red') #Click here if there is no icon file folium.Marker(location=[item['lat'], item['lon']], tooltip=item['club']+'<br>'+names, #This tooltip can be displayed by mouse over icon=iconTmp).add_to(m) #Make it the icon file specified above m.save('index.html') print ('finished!')
[Click here for source code and data files] (https://github.com/Kent747Tak/J-FootballPlayersAbroad)
Sample to display icon in Folium (English) Python Folium — A Data Visualization Superhero The sample code was easy to understand.
[Clubs of overseas soccer teams --Full screen map] (https://map.ultra-zone.net/japanese_player) At first, I saw this and wanted to make the same thing. Is this member 2012? !!
Visualize the location of hospitals in Iwate prefecture with Python folium I also referred to this in various ways.
I couldn't easily go abroad with covid-19, but personally, it's good to go around sightseeing spots when traveling abroad, but I think it's fun to watch soccer games locally. In that case, I would like you to consider a route that allows you to watch the game efficiently on this map.