Creating Bar plots kml files for Google Earth Pro using Python googleearthplot referring to this site.

### Install

Suppose pandas is installed. Install simplekml and googleearthplot.


pip install simplekml


googleearthplot is a Python2 code and some modification is required in Python3 because of an error associated with print statement. First find the location of installed googleearthplot as follows:




Edit googleearthplot.py to modify the lines of print statement by converting print **** to print(****) using parentheses.

### Usage

Open a Jupyter Notebook and import packages. Referring to the original site, some examples are shown. Double cricking on created kml file, a plot should be presented on Google Earth Pro.


import pandas as pd


#### Point plot

The following is a sample plot for a point plot.


lon=139.0 #degree
lat=35.5 #degree
gep1.PlotPoints(lat,lon,"point")
gep1.GenerateKMLFile(filepath="sample1.kml")


#### Bar plot

The following is a sample plot for bar plot.


#A bar plot
lat=35.5 #degree
lon=139.5 #degree
num=100 #bar height size
size=1  #meter
name="test"
color="red"
gep2.PlotBarChart(lat,lon,num,size,name,color)
gep2.GenerateKMLFile(filepath="sample2.kml")


You can create multiple bar plots using for loop.

#### Read data from file and create bar plot

Suppose a text data file of sample3.txt. Its contents are three columns of longitude, latitude, and height:


139.662750    35.477141   166.771019
139.663961    35.477226   171.858589
139.665148    35.477312   169.775301
139.666306    35.477394   160.395112


Read this file and create a pandas DataFrame.


fpath = "sample3.txt"
names = ["lon", "lat", "height"]
### Exclude lines of height==0
lon_p = df[df['height'] != 0.0]['lon'].values
lat_p = df[df['height'] != 0.0]['lat'].values
height_p = df[df['height'] != 0.0]['height'].values

size=2
name=None
color='red'