Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ags_grabber
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bryson Howell
ags_grabber
Commits
743c17e8
Commit
743c17e8
authored
Jul 26, 2024
by
Bryson Howell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up terrain collection code
parent
bb787a40
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
262 additions
and
167 deletions
+262
-167
feature_set.py
feature_set.py
+6
-6
indexed_incidents.csv
lp_data/indexed_incidents.csv
+65
-65
lpm_hikersim.py
lpm_hikersim.py
+78
-6
lpm_maps.py
lpm_maps.py
+113
-90
No files found.
feature_set.py
View file @
743c17e8
...
...
@@ -82,7 +82,7 @@ def grab_features(anchor_point, extent, sample_dist = 10, case_name = 'blah', he
query_cnt
=
0
while
type
(
q
)
==
list
and
query_cnt
<=
30
:
# have to do this because arcgis is sketchy as hell and doesnt always come back
try
:
print
(
"querying {} layer..."
.
format
(
name_list
[
i
]))
print
(
"
querying {} layer..."
.
format
(
name_list
[
i
]))
query_starttime
=
time
.
time
()
#Want to query where the geom filter aligns
...
...
@@ -99,13 +99,13 @@ def grab_features(anchor_point, extent, sample_dist = 10, case_name = 'blah', he
gis
=
GIS
(
url
=
'https://virginiatech.maps.arcgis.com'
)
lyr
=
FeatureLayer
(
url
=
url
,
gis
=
gis
)
print
(
"query time {}"
.
format
(
query_endtime
-
query_starttime
))
#
print("query time {}".format(query_endtime - query_starttime))
if
query_cnt
>
30
and
not
q
:
print
(
"{} layer failed too many times, leaving empty"
.
format
(
name_list
[
i
]))
continue
print
(
"{} layer sucessfully queried"
.
format
(
name_list
[
i
]))
print
(
"
%
s layer has
%
d points"
%
(
name_list
[
i
],
len
(
q
.
features
)))
print
(
"
{} layer sucessfully queried"
.
format
(
name_list
[
i
]))
print
(
"
%
s layer has
%
d points"
%
(
name_list
[
i
],
len
(
q
.
features
)))
# re-build into list of x-y values
# feat_points = []
query_dict
=
q
.
to_dict
()
...
...
@@ -200,7 +200,7 @@ def grab_features(anchor_point, extent, sample_dist = 10, case_name = 'blah', he
y_pts_inac
=
test_pts
[
mask
,
1
]
inac_endtime
=
time
.
time
()
print
(
"{} inac took {}"
.
format
(
j
,
inac_endtime
-
inac_starttime
))
#
print("{} inac took {}".format(j,inac_endtime - inac_starttime))
pts_inac
=
np
.
stack
([
x_pts_inac
,
y_pts_inac
])
.
T
...
...
@@ -275,7 +275,7 @@ def grab_features(anchor_point, extent, sample_dist = 10, case_name = 'blah', he
# save terrain as csv file (this method is pretty slow, but can compensate with interp)
if
(
get_elev
):
print
(
"Getting terrain map, this will probably take a while...."
)
print
(
"
Getting terrain map, this will probably take a while...."
)
[
e
,
e_interp
,
x
,
y
,
data
,
ll_pt
]
=
get_terrain_map
(
lat_lon
=
anchor_point
,
sample_dist
=
sample_dist
,
extent
=
extent
,
...
...
lp_data/indexed_incidents.csv
View file @
743c17e8
incident_index,area,IPP_lat,IPP_lon,find_lat,find_lon
1
,0,31.39708335,-111.20643,31.406333,-111.19683
2
,1,31.42903334,-110.29328,31.429517,-110.30412
3
,2,31.50571667,-110.67622,31.51,-110.65333
4
,3,31.72261664,-110.18783,31.741767,-110.19178
5
,4,31.83521665,-110.3567,31.862267,-110.39655
6
,5,31.90240002,-109.27847,31.8395,-109.27667
7
,6,31.92245,-109.96732,31.921483,-110.03358
8
,7,32.01236667,-109.31572,31.99935,-109.3078
9
,8,32.33333333,-110.85283,32.3715,-110.86467
10
,8,32.33583333,-110.91017,32.3665,-110.88017
1
1
,8,32.33699999,-110.91667,32.359833,-110.89767
1
2
,9,32.40916665,-110.70983,32.400833,-110.69233
1
3
,9,32.41976668,-110.74733,32.3655,-110.77583
1
4
,9,32.43543332,-110.78933,32.428833,-110.79433
1
5
,10,32.82141666,-111.20212,32.824667,-111.22717
1
6
,11,33.37055,-111.11522,33.375283,-111.08918
1
7
,12,33.38884999,-111.36565,33.4012,-111.37517
1
8
,12,33.39680001,-111.34805,33.4215,-111.3605
1
9
,12,33.39705,-111.34787,33.409333,-111.31717
20
,12,33.39733334,-111.348,33.441667,-111.36767
2
1
,12,33.39750001,-111.34783,33.415667,-111.365
2
2
,13,33.47801666,-111.43767,33.415667,-111.36478
2
3
,14,33.60398331,-112.51512,33.590333,-112.52283
2
4
,15,33.70541668,-111.33805,33.67915,-111.31695
2
5
,16,34.0927,-111.42465,34.068767,-111.43592
2
6
,16,34.09278333,-111.42098,34.102333,-111.49033
2
7
,17,34.55,-111.63333,34.55,-111.61667
2
8
,17,34.55976664,-111.65395,34.540067,-111.70348
2
9
,18,34.6,-112.55,34.633333,-112.63333
30
,18,34.63041668,-112.5553,34.627233,-112.54577
3
1
,19,34.82166665,-111.80667,34.818333,-111.79833
3
2
,19,34.82386665,-111.77513,34.831667,-111.743
3
3
,19,34.86666667,-111.88333,34.866667,-111.8
3
4
,19,34.88683332,-111.784,34.902667,-111.78683
3
5
,19,34.89333331,-111.86333,34.906667,-111.87603
3
6
,20,34.90286668,-111.81313,34.891833,-111.80482
3
7
,20,34.91666667,-111.8,34.966667,-111.86667
3
8
,20,34.92530003,-111.7341,34.897333,-111.74117
3
9
,21,34.97868334,-111.89643,34.946833,-111.88967
40
,22,35.1938,-114.05703,35.208717,-114.13195
4
1
,23,35.24375,-111.59967,35.232517,-111.6015
4
2
,24,35.33068333,-111.71108,35.334233,-111.6975
4
3
,25,36.23878333,-112.6892,36.246433,-112.70008
4
4
,26,41.54819,-80.33056,41.59006,-80.32647
4
5
,27,42.0097,-74.42595,42.03544,-74.35565
4
6
,27,42.02893,-74.33659,42.02902,-74.35191
4
7
,28,42.17965,-74.21362,42.18345,-74.19585
4
8
,29,42.31735,-76.47791,42.30271,-76.48976
4
9
,30,42.34432,-77.47638,42.36077,-77.48593
50
,31,42.74271,-73.45475,42.75163,-73.46259
5
1
,32,43.06902,-74.48481,43.05475,-74.4839
5
2
,33,43.42473,-73.73209,43.42878,-73.73981
5
3
,34,43.42498,-74.41496,43.41592,-74.4142
5
4
,34,43.42736,-74.4481,43.44347,-74.45004
5
5
,34,43.4332,-74.41433,43.45684,-74.41519
5
6
,34,43.4449,-74.4086,43.43407,-74.40747
5
7
,35,43.51063,-74.57393,43.53014,-74.57169
5
8
,36,43.65649,-76.00019,43.65566,-76.0115
5
9
,37,43.73413,-74.25577,43.73701,-74.28305
60
,38,43.8756,-74.43076,43.91132,-74.37437
6
1
,39,43.95385,-75.15748,43.99774,-75.16148
6
2
,40,44.16065,-73.85545,44.1547,-73.85942
6
3
,41,44.19013,-74.81336,44.18772,-74.79719
6
4
,42,44.28656,-74.61429,44.28923,-74.60208
6
5
,43,48.1103,-121.4917,48.142,-121.4739
0
,0,31.39708335,-111.20643,31.406333,-111.19683
1
,1,31.42903334,-110.29328,31.429517,-110.30412
2
,2,31.50571667,-110.67622,31.51,-110.65333
3
,3,31.72261664,-110.18783,31.741767,-110.19178
4
,4,31.83521665,-110.3567,31.862267,-110.39655
5
,5,31.90240002,-109.27847,31.8395,-109.27667
6
,6,31.92245,-109.96732,31.921483,-110.03358
7
,7,32.01236667,-109.31572,31.99935,-109.3078
8
,8,32.33333333,-110.85283,32.3715,-110.86467
9
,8,32.33583333,-110.91017,32.3665,-110.88017
1
0
,8,32.33699999,-110.91667,32.359833,-110.89767
1
1
,9,32.40916665,-110.70983,32.400833,-110.69233
1
2
,9,32.41976668,-110.74733,32.3655,-110.77583
1
3
,9,32.43543332,-110.78933,32.428833,-110.79433
1
4
,10,32.82141666,-111.20212,32.824667,-111.22717
1
5
,11,33.37055,-111.11522,33.375283,-111.08918
1
6
,12,33.38884999,-111.36565,33.4012,-111.37517
1
7
,12,33.39680001,-111.34805,33.4215,-111.3605
1
8
,12,33.39705,-111.34787,33.409333,-111.31717
19
,12,33.39733334,-111.348,33.441667,-111.36767
2
0
,12,33.39750001,-111.34783,33.415667,-111.365
2
1
,13,33.47801666,-111.43767,33.415667,-111.36478
2
2
,14,33.60398331,-112.51512,33.590333,-112.52283
2
3
,15,33.70541668,-111.33805,33.67915,-111.31695
2
4
,16,34.0927,-111.42465,34.068767,-111.43592
2
5
,16,34.09278333,-111.42098,34.102333,-111.49033
2
6
,17,34.55,-111.63333,34.55,-111.61667
2
7
,17,34.55976664,-111.65395,34.540067,-111.70348
2
8
,18,34.6,-112.55,34.633333,-112.63333
29
,18,34.63041668,-112.5553,34.627233,-112.54577
3
0
,19,34.82166665,-111.80667,34.818333,-111.79833
3
1
,19,34.82386665,-111.77513,34.831667,-111.743
3
2
,19,34.86666667,-111.88333,34.866667,-111.8
3
3
,19,34.88683332,-111.784,34.902667,-111.78683
3
4
,19,34.89333331,-111.86333,34.906667,-111.87603
3
5
,20,34.90286668,-111.81313,34.891833,-111.80482
3
6
,20,34.91666667,-111.8,34.966667,-111.86667
3
7
,20,34.92530003,-111.7341,34.897333,-111.74117
3
8
,21,34.97868334,-111.89643,34.946833,-111.88967
39
,22,35.1938,-114.05703,35.208717,-114.13195
4
0
,23,35.24375,-111.59967,35.232517,-111.6015
4
1
,24,35.33068333,-111.71108,35.334233,-111.6975
4
2
,25,36.23878333,-112.6892,36.246433,-112.70008
4
3
,26,41.54819,-80.33056,41.59006,-80.32647
4
4
,27,42.0097,-74.42595,42.03544,-74.35565
4
5
,27,42.02893,-74.33659,42.02902,-74.35191
4
6
,28,42.17965,-74.21362,42.18345,-74.19585
4
7
,29,42.31735,-76.47791,42.30271,-76.48976
4
8
,30,42.34432,-77.47638,42.36077,-77.48593
49
,31,42.74271,-73.45475,42.75163,-73.46259
5
0
,32,43.06902,-74.48481,43.05475,-74.4839
5
1
,33,43.42473,-73.73209,43.42878,-73.73981
5
2
,34,43.42498,-74.41496,43.41592,-74.4142
5
3
,34,43.42736,-74.4481,43.44347,-74.45004
5
4
,34,43.4332,-74.41433,43.45684,-74.41519
5
5
,34,43.4449,-74.4086,43.43407,-74.40747
5
6
,35,43.51063,-74.57393,43.53014,-74.57169
5
7
,36,43.65649,-76.00019,43.65566,-76.0115
5
8
,37,43.73413,-74.25577,43.73701,-74.28305
59
,38,43.8756,-74.43076,43.91132,-74.37437
6
0
,39,43.95385,-75.15748,43.99774,-75.16148
6
1
,40,44.16065,-73.85545,44.1547,-73.85942
6
2
,41,44.19013,-74.81336,44.18772,-74.79719
6
3
,42,44.28656,-74.61429,44.28923,-74.60208
6
4
,43,48.1103,-121.4917,48.142,-121.4739
lpm_hikersim.py
View file @
743c17e8
import
numpy
as
np
import
matplotlib
import
matplotlib.pyplot
as
plt
import
os
import
os
,
sys
,
inspect
from
os
import
path
,
getcwd
import
pandas
as
pd
#Runs replicates of lost person model on data sets collected by lpm_maps.py
currentdir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
inspect
.
getfile
(
inspect
.
currentframe
())))
parentdir
=
os
.
path
.
dirname
(
currentdir
)
sys
.
path
.
insert
(
0
,
parentdir
)
from
arcgis_terrain
import
get_terrain_map
,
lat_lon2meters
from
LostPersonModel.main_hiker
import
run_replicate
#change this import to where you have the LPM repo
#Runs replicates of lost person model on data sets collected by lpm_maps.py, producing a heatmap
#Bryson Howell, 7/24/24
def
main
(
exp_name
=
'test'
,
n_envs
=
1
,
n_iter
=
10
):
test_extent
=
20000
download_extent
=
40000
#Pull incident locations
listname
=
'./lp_data/indexed_incidents.csv'
incidents
=
pd
.
read_csv
(
listname
)
ipp_latlons
=
incidents
[[
"IPP_lat"
,
"IPP_lon"
]]
.
to_numpy
(
dtype
=
np
.
float32
())
find_latlons
=
incidents
[[
"find_lat"
,
"find_lon"
]]
.
to_numpy
(
dtype
=
np
.
float32
())
areas
=
incidents
[
'area'
]
.
to_numpy
(
dtype
=
np
.
float32
())
start
=
0
n_envs
=
np
.
size
(
np
.
unique
(
areas
))
for
i
in
range
(
start
,
start
+
n_envs
):
#Pull incident locations for environment
i_area
=
np
.
argwhere
(
areas
==
i
)
i_area
=
np
.
transpose
(
i_area
)[
0
]
s
=
'Area {0} - indices are {1}'
lst
=
[
i
,
i_area
]
print
(
s
.
format
(
*
lst
))
#test - print start / end locations on grid
grid
=
np
.
zeros
((
3000
,
3000
),
dtype
=
np
.
int8
())
for
incident
in
range
(
0
,
len
(
i_area
)):
#Dealing with large areas. Find the IPP point and resize around it
if
(
len
(
i_area
)
>
0
):
for
subzone
in
range
(
0
,
len
(
i_area
)):
#First lat/lon in area is at the center
if
(
subzone
==
0
):
sub_center
=
ipp_latlons
[
i_area
[
incident
]]
center_xy
=
lat_lon2meters
(
sub_center
[
0
],
sub_center
[
1
])
#Determine position of other IPPs from the first
else
:
cur_ipp
=
ipp_latlons
[
i_area
[
incident
+
subzone
]]
ipp_xy
=
lat_lon2meters
(
cur_ipp
[
0
],
cur_ipp
[
1
])
print
(
cur_ipp
)
#Convert
#Locate find position from IPP
#Convert both to meters
#Use extent / cell count to determine which cell we're in:
return
#Set up which environments to run through.
start
=
7
n_envs
=
1
if
(
n_envs
==
-
1
):
n_envs
=
np
.
size
(
np
.
unique
(
areas
))
#Iterate through environment datasets
for
i
in
range
(
start
,
start
+
n_envs
):
dir
=
'./map_layers/'
+
exp_name
+
'_'
+
str
(
i
)
+
'/'
#Load datasets
...
...
@@ -49,11 +111,21 @@ def main(exp_name='test', n_envs=1, n_iter=10):
map_data
=
(
bw_inac
,
bw_lf
,
elev
)
#Pull incident locations for environment
listname
=
'./lp_data/indexed_incidents.csv'
incidents
=
pd
.
read_csv
(
listname
)
latlons
=
incidents
[[
"IPP_lat"
,
"IPP_lon"
]]
.
to_numpy
(
dtype
=
np
.
float32
())
areas
=
incidents
[
'area'
]
.
to_numpy
(
dtype
=
np
.
float32
())
i_area
=
np
.
argwhere
(
areas
==
i
)
i_area
=
np
.
transpose
(
i_area
)[
0
]
for
incident
in
range
(
0
,
len
(
i_area
)):
#s = 'Environment {0} - start {1} find {2}'
#s_lst = [i,]
print
()
#For large downloads, re-size and center on IPP
#if(len(i_area) > 1)):
#for j in range
#we know initial point is at 0,0 but where is the final point...?
return
...
...
lpm_maps.py
View file @
743c17e8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment