Skip to content
Snippets Groups Projects
Commit fe57f69e authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

implementation of generate_array_from_positions

parent 1df048b1
No related branches found
No related tags found
3 merge requests!12version 0.2a,!10Resolve "Image creation bugs with 0 size windows",!9Resolve "Creation of images from AIS"
...@@ -223,3 +223,21 @@ class AISTrajectory(AISPoints): ...@@ -223,3 +223,21 @@ class AISTrajectory(AISPoints):
current_label = row[label_column] current_label = row[label_column]
result.append((row['ts_sec'], current_label)) result.append((row['ts_sec'], current_label))
return result return result
def generate_array_from_positions(self, height=256, width=256, link=True, bounding_box='fit', features=None):
nb_channels = 1
if features is not None:
nb_channels = len(features)
data = np.zeros((height, width, nb_channels), dtype=np.uint8)
if link:
raise ValueError("feature not implemented")
if bounding_box != 'fit':
raise ValueError("feature not implemented")
positions = self.df[['longitude', 'latitude']].to_numpy()
range_longitude = (min(positions[0, :]), max(positions[0, :]))
range_latitude = (min(positions[1, :]), max(positions[1, :]))
for longitude, latitude in positions:
x_coord = width * (longitude - range_longitude[0]) / (range_longitude[1] - range_longitude[0])
y_coord = height * (longitude - range_latitude[0]) / (range_latitude[1] - range_latitude[0])
data[x_coord, y_coord, :] = 1
return data
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment