-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32a82d4
commit 1ec79a0
Showing
11 changed files
with
168 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
id: g1i0o9ctmib83n4mydtsqfo | ||
title: Automatic identification system | ||
desc: "" | ||
updated: 1708461719224 | ||
created: 1708461557185 | ||
--- | ||
|
||
The automatic identification system (AIS) is an automatic tracking system that uses transceivers on ships and is used by vessel traffic services (VTS). When satellites are used to receive AIS signatures, the term Satellite-AIS (S-AIS) is used. AIS information supplements marine radar, which continues to be the primary method of collision avoidance for water transport. Although technically and operationally distinct, the ADS-B system is analogous to AIS and performs a similar function for aircraft.[^1] | ||
|
||
## Limits | ||
|
||
- out of range | ||
- intense traffic area | ||
- expensive | ||
|
||
## Data source | ||
|
||
https://spire.com/maritime/ | ||
|
||
[^1]: https://en.wikipedia.org/wiki/Automatic_identification_system |
18 changes: 10 additions & 8 deletions
18
documentation/database_init.md → docs/notes/database.initialisation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
# Database initialisation and versioning | ||
|
||
|
||
## Database initialisation | ||
--- | ||
id: 8vo1vo09y37hwnrkmcy7w77 | ||
title: Database initialisation | ||
desc: "" | ||
updated: 1708410470701 | ||
created: 1708410417004 | ||
--- | ||
|
||
First you need to run scripts which are in alembic/init_script : | ||
|
||
- the load_vessels_data.py script will load vessels metadata from the data/chalutier_pelagique.csv file. | ||
- the load_geometry_data.py file will load shape data from the Nonterrestrial_WDPA_Jan2023.shp file. This file is not included in this github project but you can ask for it. It's only used for the alerting part. | ||
|
||
The second step is to load the [distance-from-port-v20201104.tiff](https://globalfishingwatch.org/data-download/datasets/public-distance-from-port-v1) and [distance-from-shore.tif](https://globalfishingwatch.org/data-download/datasets/public-distance-from-shore-v1) files. They are only used for the alerting part. | ||
|
||
- install psql and raster2pgsql. | ||
- install raster type in db with postgis-raster using `create extension postgis_raster` | ||
- adapt this command for each file : `raster2pgsql -t auto -I -C -M /PATH_TO/distance-from-shore.tif public.distance_shore | PGPASSWORD='POSTGRES_PASSWORD' psql -h POSTGRES_HOSTNAME -d POSTGRES_DB -U POSTGRES_USER -p POSTGRES_PORT` | ||
|
||
## Database versioning | ||
The command ` alembic upgrade head` can be used in the root of the project in order to update the database schema to the last version. | ||
- adapt this command for each file : `raster2pgsql -t auto -I -C -M /PATH_TO/distance-from-shore.tif public.distance_shore | PGPASSWORD='POSTGRES_PASSWORD' psql -h POSTGRES_HOSTNAME -d POSTGRES_DB -U POSTGRES_USER -p POSTGRES_PORT` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: kofmnl4h6i8e9uacvtd2wkr | ||
title: Database versioning | ||
desc: "" | ||
updated: 1708410507271 | ||
created: 1708410490074 | ||
--- | ||
|
||
The command ` alembic upgrade head` can be used in the root of the project in order to update the database schema to the last version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: iuuwulp9e75lg0jd18l0wyp | ||
title: Poetry | ||
desc: '' | ||
updated: 1708410825991 | ||
created: 1708410825991 | ||
--- | ||
|
||
[Poetry](https://python-poetry.org/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
id: t40gr1j4y9jqm2ba4yh7xuf | ||
title: Marine Protected Areas | ||
desc: "" | ||
updated: 1708461758182 | ||
created: 1708461744075 | ||
--- | ||
|
||
- https://www.cell.com/one-earth/fulltext/S2590-3322(20)30150-0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
id: dxdppizit5jtxu6cuwl6kz6 | ||
title: Shom | ||
desc: "" | ||
updated: 1708461781678 | ||
created: 1708461768767 | ||
--- | ||
|
||
- https://www.shom.fr/ | ||
|
||
pour visualiser les droits miles nautique et les droits historiques |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
id: dgw0omk9y2u92olzvdxgddp | ||
title: Useful SQL examples | ||
desc: "" | ||
updated: 1708410750577 | ||
created: 1708410619351 | ||
--- | ||
|
||
## List of mmi scrapped since last update | ||
|
||
```sql | ||
SELECT mmsi as tm FROM spire_vessel_positions WHERE timestamp > '2023-06-17' GROUP BY mmsi | ||
``` | ||
|
||
## More recent timestamp scrapped since last update | ||
|
||
```sql | ||
SELECT tm,array_agg(mmsi) FROM (SELECT mmsi,max(timestamp) as tm FROM spire_vessel_positions WHERE timestamp > '2023-06-17' GROUP BY mmsi) as foo GROUP BY tm | ||
``` | ||
|
||
## mmsi not scrapped by Spire | ||
|
||
```sql | ||
SELECT mmsi FROM vessels WHERE mmsi IS NOT NULL AND mmsi NOT IN (SELECT mmsi as tm FROM spire_vessel_positions WHERE timestamp > '2023-06-17' GROUP BY mmsi) | ||
``` | ||
|
||
## number of distincte position per boat which has more than 1000 positions gathered | ||
|
||
```sql | ||
SELECT * FROM (SELECT COUNT(*) as sum_position,mmsi FROM (SELECT DISTINCT position,mmsi FROM spire_vessel_positions) as foo GROUP BY mmsi) as bar WHERE sum_position > 1000 | ||
``` |
Oops, something went wrong.