我有一个数据框,其中包含纬度、经度、HWMQalityName、高程、描述和其他非必要信息的列。下面显示的数据框仅用于纬度、经度、HWMQalityName、高程和说明。在纬度列之前、描述列之后以及纬度、经度、HWMQalityName、elev_ft和hwm_locationdescription列之间的数据帧中,还有其他列的值:
import numpy as np
import matplotlib.pyplot as plt
import netCDF4 as nc4
import os
import sys
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
import plotly.offline as po
import plotly.graph_objs as go
from mpl_toolkits.basemap import Basemap
import pathlib as pl
import matplotlib as mpl
import pandas as pd
import sys;sys.path.append('../ncsurge')
from importlib import reload
import geopandas as gpd
from shapely.geometry import Point, MultiPoint
from shapely.ops import nearest_points
from hwm import *
root_hwm = pl.Path(r'P:\Temp\bpozo\Scripts\HWM')
A = pd.read_csv(str(root_hwm / 'FilteredHWMs.csv'))
hwm_m = gpd.GeoDataFrame(A)
hwm_m
latitude longitude hwmQualityName elev_ft hwm_locationdescription
35.281050926 -76.6625853795 'Excellent: +/- 0.05 ft' 7.288 'side of left garage'
34.676933 -77.080633 'Poor: +/- 0.40 ft' 12.241 'outside marked with pen'
...
34.94107586 -76.6507665736 'Good: +/- 0.10 ft' 6.025 'side of post'
这些点中有一定数量(比如说100个)位于海岸线上,当在地图上看到时,它们彼此相对较近。我想做的是几件事:
1)我想将每个位置的标高值与周围位置的标高值进行比较,半径为300英尺,以确定我所查看位置的标高值是否为异常值
2)确定具有异常值的高程值的位置后,我想使用HWMQalityName列和hwm_locationdescription列中的字符串删除HWMQalityName列中包含单词“Poor”或hwm_locationdescription列中包含单词“waves”或与waves相关的任何其他单词的所有点(即从数据帧中删除整行)
我希望最终得到的是一个数据帧,它根据上述条件删除了点
我是Python新手,不知道解决这个问题的最佳方法
任何和所有的帮助都将不胜感激
你有坐标,你想给出一个以英尺为单位的半径。如果你把脚转换成坐标,你的工作就会轻松得多。经度和纬度通常以度、分和秒为单位,1秒约为90英尺。300英尺=3.3秒=0.055分钟=0.00092度。我将数字四舍五入,因为看起来你不需要对距离进行超级精确,但它仍然应该精确到<;10英尺
然后可以找到计算一个坐标是否在另一个坐标范围内的数学Here
我相信距离函数对于第1部分是有用的。以下是我在网上制作/发现的一个:
您可以使用此函数确定其“300英尺”部分。我应该注意到,它返回的是以米为单位的距离,我不确定其准确性。我相信当我测试它的时候,它的功能是99.8%的准确度,但是如果你测量到脚,那可能不够准确
要归功于我找到数学的地方:https://www.movable-type.co.uk/scripts/latlong.html
相关问题 更多 >
编程相关推荐