1

Anyone can guide how to can I plot a column value against Lat & Long. The data which I want to plot through python is mentioned below. I have run the code but it isn't working. Kindly guide me on how to do it

Data in CSV File :

Longitude Latitude   RSRP
71.676847 29.376015  -89 
71.676447 29.376115  -101
71.677847 29.376215  -90

Code :

import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt


df = pd.read_csv('C:\\Users\\uwx630237\\BWPMR.csv')
gdf = gpd.GeoDataFrame(df)
Lon = df['Longitude']
Lat = df['Latitude']
RSRP = df['RSRP']

Required Ouput Picture

gehbiszumeis
  • 3,525
  • 4
  • 24
  • 41

2 Answers2

0

Without map as background on the plot, you can use df.plot.scatter(). Here is the relevant lines of code that you can try:

# ... previous lines of code

# add a column, named `color`, and set values in it
df.loc[:, 'color'] = 'green'                # set all rows -> color=green
df.loc[df['RSRP'] < -100, 'color'] = 'red'  # set some rows -> color=red

# plot the data as a scatter plot
df.plot.scatter( x='Longitude' , y='Latitude', s=20, color=df['color'], alpha=0.8 )

The output will look like this:

enter image description here

swatchai
  • 17,400
  • 3
  • 39
  • 58
-1

You can achieve that using folium. Here is a toy example how to add data to a map of San Francisco

import foilum
import folium.plugins
import branca
import branca.colormap as cm

colormap = cm.LinearColormap(colors=['red','lightblue'], index= 90,100],vmin=90,vmax=100)
sanfrancisco_map = folium.Map(location=[37.77, -122.42], zoom_start=12)

lat = list(df.latitude)
lon = list(df.longitude)
RSRP = list(df.RSRP)


for loc, RSRP in zip(zip(lat, lon), RSRP):
    folium.Circle(
        location=loc,
        radius=10,
        fill=True,
        color=colormap(p),
        
    ).add_to(map)

# add incidents to map
sanfran_map.add_child(colormap)
TiTo
  • 833
  • 2
  • 7
  • 28
  • I want to plot RSRP value on the adjacent Lat Long.You are putting Lat Long only. – Usman Nomani Jul 23 '20 at 09:27
  • Ok I did not understand that from your question. Adjusted my answer accordingly. https://stackoverflow.com/a/56878525/12934163 here is a similar answer you could also make use of – TiTo Jul 23 '20 at 09:40
  • How can I add legend in the picture 0 to -100 green color -100 to -140 yellow color – Usman Nomani Aug 03 '20 at 12:43
  • Does that help? https://stackoverflow.com/a/52981290/12934163. Did you mange to create your map? – TiTo Aug 05 '20 at 13:22