forked from venetoarpa/Arpav-PPCV-backend
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add newer version of municipalities (#197)
- Loading branch information
1 parent
156d027
commit 5358dc5
Showing
10 changed files
with
1,277 additions
and
156 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
33 changes: 33 additions & 0 deletions
33
arpav_ppcv/migrations/versions/2c0e4144c2ec_added_municipality_centroid_coords.py
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,33 @@ | ||
"""added-municipality-centroid-coords | ||
Revision ID: 2c0e4144c2ec | ||
Revises: d445c73f5aef | ||
Create Date: 2024-08-20 18:09:27.462147 | ||
""" | ||
from typing import Sequence, Union | ||
|
||
from alembic import op | ||
import sqlalchemy as sa | ||
import sqlmodel | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision: str = '2c0e4144c2ec' | ||
down_revision: Union[str, None] = 'd445c73f5aef' | ||
branch_labels: Union[str, Sequence[str], None] = None | ||
depends_on: Union[str, Sequence[str], None] = None | ||
|
||
|
||
def upgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('municipality', sa.Column('centroid_epsg_4326_lon', sa.Float(), nullable=True)) | ||
op.add_column('municipality', sa.Column('centroid_epsg_4326_lat', sa.Float(), nullable=True)) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade() -> None: | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('municipality', 'centroid_epsg_4326_lat') | ||
op.drop_column('municipality', 'centroid_epsg_4326_lon') | ||
# ### end Alembic commands ### |
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
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,53 @@ | ||
# ARPAV-PPCV auxiliary datasets | ||
|
||
|
||
### Italian municipalities | ||
|
||
The `municipalities-istat-2021.geojson` file holds a dataset with italian municipalities that are part of the | ||
relevant regions for the ARPAV-PPCV system, namely: | ||
|
||
- Friuli Venezia Giulia | ||
- Trentino-Alto Adige | ||
- Veneto | ||
|
||
The ARPAV-PPCV system expects each municipality feature to have the following properties: | ||
|
||
- `fid` | ||
- `name` | ||
- `province_name` | ||
- `region_name` | ||
- `xcoord` - longitude of the centroid, in EPSG:4326 | ||
- `ycoord` - latitude of the centroid, in EPSG:4326 | ||
|
||
The system also expects features to have a geometry type of `MultiPolygon` | ||
|
||
|
||
This dataset has been prepared from the official ISTAT datasets, which are made available publicly at: | ||
|
||
https://www.istat.it/notizia/confini-delle-unita-amministrative-a-fini-statistici-al-1-gennaio-2018-2/ | ||
|
||
The dataset currently in use is the one for the year 2021. This was chosen as this was the latest bundle which | ||
included the relevant centroid information for each municipality in the companion .xlsx file. | ||
|
||
The original downloaded dataset consisted of a zingle zip file which decompressed into multiple files, for which the | ||
following were relevant: | ||
|
||
- ProvCM2021/ProvCM2021.sh* - geospatial boundaries of all italian municipalities | ||
- ElencoUnitaAmministrative2021.xlsx - relevant alphanumerical information about municipalities, including the | ||
coordinates of the points which should be regarded as the centroid | ||
|
||
The original dataset was pre-processed into the `municipalities-istat-2021.geojson` present in this directory. | ||
Pre-processing consisted mainly in the following operations: | ||
|
||
- Discard all municipalities which do not belong to the any of the target regions | ||
- Include the name of the province and the name of the region for each municipality | ||
- Extract the x and y coordinates from the .xlsx which represent municipality centroids and join them with the | ||
respective municipality | ||
- Reproject the geometries and also the x and and y coordinates of centroids to `EPSG:4326` | ||
- Save the result as a GeoJSON file | ||
|
||
This dataset is ingested into the ARPAV-PPCV system database by running the command: | ||
|
||
```shell | ||
arpav-ppcv bootstrap municipalities data/municipalities-istat-2021.geojson | ||
``` |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1,068 changes: 1,067 additions & 1 deletion
1,068
data/limits_IT_municipalities.geojson → data/municipalities-istat-2021.geojson
Large diffs are not rendered by default.
Oops, something went wrong.
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