Skip to content

Commit

Permalink
enrichissement avec cog
Browse files Browse the repository at this point in the history
  • Loading branch information
linogaliana committed Dec 26, 2023
1 parent 1486fa9 commit 88152b8
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 19 additions & 4 deletions cartiflette/mapshaper/mapshaper_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,32 @@ def mapshaperize_split(
else:
option_simplify = ""

cmd = (
f"mapshaper {local_dir}/{filename_initial}.{extension_initial} name='' -proj EPSG:{crs} "
# STEP 1: ENRICHISSEMENT AVEC COG
cmd_step1 = (
f"mapshaper {local_dir}/{filename_initial}.{extension_initial} "
f"name='' -proj EPSG:{crs} "
f"-join temp/tagc.csv "
f"keys=INSEE_COM,CODGEO field-types=INSEE_COM:str,CODGEO:str "
"-filter-fields INSEE_CAN,INSEE_ARR,SIREN_EPCI,DEP,REG invert "
"-o temp.geojson"
)

subprocess.run(
cmd_step1,
shell=True
)

# STEP 2: SPLIT ET SIMPLIFIE
cmd_step2 = (
f"mapshaper temp.geojson name='' -proj EPSG:{crs} "
f"{option_simplify}"
f"-each \"SOURCE='{provider}:{source}'\" "
f"-split {dict_corresp[niveau_agreg]} "
f"-o {output_path} format={format_output} extension=\".{format_output}\" singles"
)


subprocess.run(
cmd,
cmd_step2,
shell=True
)

Expand Down
6 changes: 4 additions & 2 deletions misc/prototype_mapshaper.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# IGN DATASET
path_bucket_adminexpress = upload_s3_raw(
path_within_bucket=path_within_bucket,
year = 2022
year=2022
)

path_bucket_cog_commune = upload_s3_raw(
Expand Down Expand Up @@ -107,12 +107,14 @@
cog_metadata
)

tagc_metadata.drop(columns = ["LIBGEO"]).to_csv("temp/tagc.csv")



# TEST MAPSHAPERIZE

mapshaperize_split_from_s3(
path_bucket,
path_bucket_adminexpress,
{
'path_within_bucket': path_within_bucket,
"borders": "COMMUNE",
Expand Down

0 comments on commit 88152b8

Please sign in to comment.