Skip to content

Commit

Permalink
Update datasets with resolution config
Browse files Browse the repository at this point in the history
  • Loading branch information
tgrandje committed Sep 25, 2024
1 parent 24f6e06 commit 97d3ee1
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 32 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ COPY docker/test.py .
RUN curl https://install.python-poetry.org/ | python -
RUN poetry install --only main --no-interaction

# TODO : is this necessary? This should throw an exception if datasets have not
# already been (manually) uploaded ?
CMD ["python", "test.py"]
11 changes: 7 additions & 4 deletions argo-pipeline/api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""A simple API to expose cartiflette files"""

import typing
from fastapi import FastAPI, Response
from fastapi.responses import FileResponse

from cartiflette.api import download_from_cartiflette_inner
from cartiflette.config import PATH_WITHIN_BUCKET
from cartiflette.config import PATH_WITHIN_BUCKET, DATASETS_HIGH_RESOLUTION
from cartiflette.pipeline_constants import COG_TERRITOIRE # , IRIS

app = FastAPI(
title="API de récupération des fonds de carte avec <code>cartiflette</code>",
Expand Down Expand Up @@ -42,9 +44,10 @@ def download_from_cartiflette_api(
year=2022,
crs=4326,
simplification=simplification,
provider="IGN",
dataset_family="ADMINEXPRESS",
source="EXPRESS-COG-CARTO-TERRITOIRE",
provider="Cartiflette",
dataset_family="production",
# TODO : source can also be IRIS[DATASETS_HIGH_RESOLUTION]
source=COG_TERRITOIRE[DATASETS_HIGH_RESOLUTION],
return_as_json=False,
path_within_bucket=PATH_WITHIN_BUCKET,
)
Expand Down
14 changes: 8 additions & 6 deletions argo-pipeline/src/split_merge_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

from s3fs import S3FileSystem

from cartiflette.config import BUCKET, PATH_WITHIN_BUCKET, FS
from cartiflette.pipeline import (
mapshaperize_split_from_s3,
# mapshaperize_merge_split_from_s3,
from cartiflette.config import (
BUCKET,
PATH_WITHIN_BUCKET,
FS,
DATASETS_HIGH_RESOLUTION,
)

from cartiflette.pipeline import mapshaperize_split_from_s3
from cartiflette.pipeline_constants import COG_TERRITOIRE

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
Expand All @@ -46,7 +48,7 @@
parser.add_argument(
"-so",
"--source",
default="EXPRESS-COG-CARTO-TERRITOIRE",
default=COG_TERRITOIRE[DATASETS_HIGH_RESOLUTION],
help="Select upstream raw source to use for geometries",
)
parser.add_argument(
Expand Down
42 changes: 22 additions & 20 deletions cartiflette/pipeline/mapshaper_split_from_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,25 @@ def mapshaperize_split_from_s3(
return {"success": len(success), "skipped": len(skipped)}


if __name__ == "__main__":
import logging

logging.basicConfig(level=logging.INFO)

mapshaperize_split_from_s3(
year=2023,
init_geometry_level="ARRONDISSEMENT_MUNICIPAL",
source="EXPRESS-COG-CARTO-TERRITOIRE",
simplification=40,
dissolve_by="DEPARTEMENT",
config_generation={
"FRANCE_ENTIERE_DROM_RAPPROCHES": [
{"format_output": "gpkg", "epsg": "4326"},
{"format_output": "geojson", "epsg": "4326"},
{"format_output": "gpkg", "epsg": "2154"},
{"format_output": "geojson", "epsg": "2154"},
]
},
)
# if __name__ == "__main__":
# import logging
# from cartiflette.pipeline_constants import COG_TERRITOIRE
# from cartiflette.config import DATASETS_HIGH_RESOLUTION

# logging.basicConfig(level=logging.INFO)

# mapshaperize_split_from_s3(
# year=2023,
# init_geometry_level="ARRONDISSEMENT_MUNICIPAL",
# source=COG_TERRITOIRE[DATASETS_HIGH_RESOLUTION],
# simplification=40,
# dissolve_by="DEPARTEMENT",
# config_generation={
# "FRANCE_ENTIERE_DROM_RAPPROCHES": [
# {"format_output": "gpkg", "epsg": "4326"},
# {"format_output": "geojson", "epsg": "4326"},
# {"format_output": "gpkg", "epsg": "2154"},
# {"format_output": "geojson", "epsg": "2154"},
# ]
# },
# )
4 changes: 3 additions & 1 deletion cartiflette/pipeline/prepare_geodatasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
PATH_WITHIN_BUCKET,
THREADS_DOWNLOAD,
INTERMEDIATE_FORMAT,
DATASETS_HIGH_RESOLUTION,
)
from cartiflette.pipeline_constants import (
PIPELINE_DOWNLOAD_ARGS,
PIPELINE_SIMPLIFICATION_LEVELS,
COG_TERRITOIRE,
)
from cartiflette.s3.geodataset import (
S3GeoDataset,
Expand Down Expand Up @@ -187,7 +189,7 @@ def create_one_year_geodataset_batch(
"path_within_bucket": path_within_bucket,
"provider": "IGN",
"dataset_family": "ADMINEXPRESS",
"source": "EXPRESS-COG-CARTO-TERRITOIRE",
"source": COG_TERRITOIRE[DATASETS_HIGH_RESOLUTION],
"borders": None,
"crs": "*",
"filter_by": "origin",
Expand Down
6 changes: 5 additions & 1 deletion docker/test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import subprocess
from cartiflette import carti_download
from cartiflette.pipeline_constants import COG_TERRITOIRE
from cartiflette.config import DATASETS_HIGH_RESOLUTION

ile_de_france = carti_download(
values=["11"],
crs=4326,
borders="DEPARTEMENT",
vectorfile_format="geojson",
filter_by="REGION",
source="EXPRESS-COG-CARTO-TERRITOIRE",
source=COG_TERRITOIRE[DATASETS_HIGH_RESOLUTION],
year=2022,
provider="Cartiflette",
dataset_family="production",
)

ile_de_france.to_file("idf.json")
Expand Down

0 comments on commit 97d3ee1

Please sign in to comment.