地理坐标上的抖动功能(纬度/经度) [英] Jitter function on Geographic coordinates (Latitude/longitudes)

查看:415
本文介绍了地理坐标上的抖动功能(纬度/经度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下情况:

我有一个数据集,其中每一行代表一个学生.

I have a dataset where each row represent a student.

Student_ID School_ID School_Lat  School_Long

  12221      14a      -22.7324    -47.6533

  12344      14a      -22.7324    -47.6533

您会注意到,如果学生属于同一所学校,则该学校的geocod将会是相同的.

You can notice that if the student belongs to the same school, the school's geocod will be the same.

我正在尝试创建抖动效果,以便在基于学校ID的地图上代表所有学生.

I am trying to create a jitter effect in order to represent all the student in a map based on school id.

示例:

我不想在地图中将多个点表示为单个点,而是想在学校周围创建点,以表示属于该学校的学生.

Instead of represent many dots into one single point in a map, I would like to create points around the school, to represent the students that belong to that school.

可以使用熊猫groupby('School_ID')来应用的功能,该功能可以在坐标上创建此最小的修改.

A function that can be applied using pandas groupby('School_ID') that creates this minimal modification on coordinates.

推荐答案

在绘图库级别的解决方案是完美的.

Solution on plotting library level is perfect.

但是,如果要对地图进行手动抖动效果,则不必按School_ID分组.

But if you want to do manually jitter effect for map you don't have to group by School_ID.

sigma需要通过实验选择:

sigma = 0.1
df['School_Lat'] = df['School_Lat'].apply(lambda x: x + np.random.normal(x, sigma, 1))
df['School_Long'] = df['School_Long'].apply(lambda x: x + np.random.normal(x, sigma, 1))

这篇关于地理坐标上的抖动功能(纬度/经度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆