Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
skais
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Raphael Sturgis
skais
Merge requests
!9
Resolve "Creation of images from AIS"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Creation of images from AIS"
16-creation-of-images-from-ais
into
develop
Overview
0
Commits
6
Pipelines
0
Changes
5
Merged
Raphael Sturgis
requested to merge
16-creation-of-images-from-ais
into
develop
3 years ago
Overview
0
Commits
6
Pipelines
0
Changes
5
Expand
Closes
#16 (closed)
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
4257ce4a
6 commits,
3 years ago
5 files
+
219
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
5
Search (e.g. *.vue) (Ctrl+P)
skais/ais/ais_trajectory.py
+
39
−
3
Options
@@ -5,8 +5,9 @@ import numpy as np
from
numba
import
jit
from
scipy.interpolate
import
interp1d
from
skais.utils.geography
import
great_circle
,
position_from_distance
from
skais.utils.geography
import
great_circle
,
position_from_distance
,
get_coord
from
skais.ais.ais_points
import
AISPoints
from
skais.utils.geometry
import
bresenham
@jit
(
nopython
=
True
)
@@ -223,3 +224,38 @@ class AISTrajectory(AISPoints):
current_label
=
row
[
label_column
]
result
.
append
((
row
[
'
ts_sec
'
],
current_label
))
return
result
def
generate_array_from_positions
(
self
,
height
=
256
,
width
=
256
,
link
=
True
,
bounding_box
=
'
fit
'
,
features
=
None
,
node_size
=
0
):
nb_channels
=
1
if
features
is
not
None
:
nb_channels
=
len
(
features
)
data
=
np
.
zeros
((
height
,
width
,
nb_channels
),
dtype
=
np
.
uint8
)
if
bounding_box
!=
'
fit
'
:
raise
ValueError
(
"
feature not implemented
"
)
positions
=
self
.
df
[[
'
longitude
'
,
'
latitude
'
]].
to_numpy
()
min_lon
,
max_lon
=
(
min
(
positions
[:,
0
]),
max
(
positions
[:,
0
]))
min_lat
,
max_lat
=
(
min
(
positions
[:,
1
]),
max
(
positions
[:,
1
]))
for
longitude
,
latitude
in
positions
:
x_coord
,
y_coord
=
get_coord
(
latitude
,
longitude
,
height
,
width
,
min_lat
,
max_lat
,
min_lon
,
max_lon
)
x_lower_bound
=
max
(
0
,
x_coord
-
node_size
)
x_upper_bound
=
min
(
height
-
1
,
x_coord
+
node_size
)
y_lower_bound
=
max
(
0
,
y_coord
-
node_size
)
y_upper_bound
=
min
(
width
-
1
,
y_coord
+
node_size
)
for
x
in
range
(
x_lower_bound
,
x_upper_bound
+
1
):
for
y
in
range
(
y_lower_bound
,
y_upper_bound
+
1
):
data
[
x
,
y
]
=
[
1
]
if
link
:
lon
,
lat
=
positions
[
0
,
0
],
positions
[
0
,
1
]
for
longitude
,
latitude
in
positions
[
1
:]:
x_prv
,
y_prev
=
get_coord
(
lat
,
lon
,
height
,
width
,
min_lat
,
max_lat
,
min_lon
,
max_lon
)
x_nxt
,
y_nxt
=
get_coord
(
latitude
,
longitude
,
height
,
width
,
min_lat
,
max_lat
,
min_lon
,
max_lon
)
lon
,
lat
=
longitude
,
latitude
for
x
,
y
in
bresenham
(
x_prv
,
y_prev
,
x_nxt
,
y_nxt
):
data
[
x
,
y
]
=
[
1
]
return
data
Loading