some improvements
This commit is contained in:
@@ -45,19 +45,20 @@ def get_dir_vector(polygon1,polygon2):
|
|||||||
lat1,lon1 = polygon_coord_center(polygon1)
|
lat1,lon1 = polygon_coord_center(polygon1)
|
||||||
lat2,lon2 = polygon_coord_center(polygon2)
|
lat2,lon2 = polygon_coord_center(polygon2)
|
||||||
|
|
||||||
return [[lat1,lon1],[lat2,lon2]]
|
return [lat2-lat1,lon2-lon1]
|
||||||
|
|
||||||
def get_delta(vector,polygon):
|
def get_delta(vector,polygon):
|
||||||
x = pd.Series(range(10000))/9999.
|
x = pd.Series(range(10000))/9999.
|
||||||
lat1 = vector[0][0]
|
vlat = vector[0]
|
||||||
lon1 = vector[0][1]
|
vlon = vector[1]
|
||||||
lat2 = vector[1][0]
|
|
||||||
lon2 = vector[1][0]
|
|
||||||
|
|
||||||
lat = x.apply(lambda x:lat1+x*(lat2-lat1))
|
lat1,lon1 = polygon_coord_center(polygon)
|
||||||
lon = x.apply(lambda x:lon1+x*(lon2-lon1))
|
|
||||||
|
lat = x.apply(lambda x:lat1+x*vlat)
|
||||||
|
lon = x.apply(lambda x:lon1+x*vlon)
|
||||||
|
|
||||||
totdist,bearing = geo_distance(lat1,lon1,lat2,lon2)
|
totdist,bearing = geo_distance(lat1,lon1,lat1+vlat,lon1+vlat)
|
||||||
|
print totdist
|
||||||
|
|
||||||
dist = x*totdist
|
dist = x*totdist
|
||||||
|
|
||||||
@@ -73,10 +74,12 @@ def get_delta(vector,polygon):
|
|||||||
|
|
||||||
df['inpolygon'] = df.apply(f,axis=1)
|
df['inpolygon'] = df.apply(f,axis=1)
|
||||||
|
|
||||||
b = (~df['inpolygon']).shift(1)+df['inpolygon']
|
|
||||||
|
b = (~df['inpolygon']).shift(-1)+df['inpolygon']
|
||||||
|
|
||||||
|
|
||||||
if len(df[b==2]):
|
if len(df[b==2]):
|
||||||
return df[b==2]['dist'].min()
|
return 1.0e3*df[b==2]['dist'].min()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user