carti_download
carti_download(
values,
borders='COMMUNE',
filter_by='REGION',
territory='metropole',
vectorfile_format='auto',
year=None,
crs=4326,
simplification=None,
bucket=BUCKET,
path_within_bucket=PATH_WITHIN_BUCKET,
provider='IGN',
dataset_family='ADMINEXPRESS',
source='EXPRESS-COG-CARTO-TERRITOIRE',
filename='raw',
return_as_json=False,
engine='geopandas',
con=None,
force=False,
)Download official French borders produced by cartiflette.
Everything is done with DuckDB; with the default engine, the result is converted into a GeoDataFrame at the end.
- GeoJSON: one file per value of
filter_by; the list of links is built and DuckDB reads the files together. - GeoParquet (from 2025 onwards, and some earlier years): one file per level; DuckDB filters it and only downloads the needed parts.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| values | list or str or int | Values of filter_by to retrieve (e.g. [“11”, “84”] for REGION, “France” for FRANCE_ENTIERE). Region codes below 10 can be given as 1, “1” or “01”. |
required |
| borders | str | Level of the polygons: COMMUNE, COMMUNE_ARRONDISSEMENT, DEPARTEMENT, REGION, BASSIN_VIE, ZONE_EMPLOI, UNITE_URBAINE, AIRE_ATTRACTION_VILLES. | 'COMMUNE' |
| filter_by | str | Level used to select the polygons: DEPARTEMENT, REGION, TERRITOIRE, FRANCE_ENTIERE, FRANCE_ENTIERE_DROM_RAPPROCHES or a zoning. | 'REGION' |
| territory | str | Kept for compatibility with the storage layout of the GeoJSON files, “metropole”. | 'metropole' |
| vectorfile_format | str | “auto” (default), “geojson” or “parquet”. GeoParquet is read whenever it exists, even if “geojson” is requested, unless force is True; see choose_format, parquet_available and geojson_available. |
'auto' |
| year | str or int | Vintage of the borders. Defaults to the current year. | None |
| crs | str or int | EPSG code of the projection. Default 4326. | 4326 |
| simplification | int | Simplification level (percentage of points removed): 0 or 50. | None |
| bucket | str | Bucket of the files, “projet-cartiflette”. | BUCKET |
| path_within_bucket | str | Prefix within the bucket: “production” for the published files, or a test location such as “test/v0.3.0”. | PATH_WITHIN_BUCKET |
| provider | str | Provider of the data, “IGN”. | 'IGN' |
| dataset_family | str | Dataset family, “ADMINEXPRESS”. | 'ADMINEXPRESS' |
| source | str | Source label in the paths, “EXPRESS-COG-CARTO-TERRITOIRE”. | 'EXPRESS-COG-CARTO-TERRITOIRE' |
| filename | str | Name of the file without extension, “raw”. | 'raw' |
| return_as_json | bool | If True, return a GeoJSON string. | False |
| engine | str | “geopandas” (default): return a GeoDataFrame. “duckdb”: return the DuckDB relation, not evaluated yet, to go on with SQL. | 'geopandas' |
| con | duckdb.DuckDBPyConnection | DuckDB connection to use (e.g. to join the result with other data). By default, an in-memory connection shared by all the calls. | None |
| force | bool | Read GeoJSON when vectorfile_format="geojson" even if GeoParquet exists for the year. A warning recalls that GeoParquet is faster. Only for years with GeoJSON files (2022): none is published from 2025 onwards, so GeoParquet is read anyway, with a warning. |
False |
Returns
| Name | Type | Description |
|---|---|---|
| geopandas.GeoDataFrame or duckdb.DuckDBPyRelation or str |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | If vectorfile_format or engine is not supported; GeoParquet only: if borders cannot be filtered by filter_by, or if some values are not found. |
|
| OSError | If a file cannot be found. |
Examples
Departements with the DROM brought closer to metropolitan France:
>>> from cartiflette import carti_download
>>> gdf = carti_download(
... values=["France"],
... borders="DEPARTEMENT",
... filter_by="FRANCE_ENTIERE_DROM_RAPPROCHES",
... simplification=50,
... year=2022,
... )Communes of two regions, kept in DuckDB:
>>> rel = carti_download(
... values=["11", "84"],
... borders="COMMUNE",
... filter_by="REGION",
... year=2025,
... engine="duckdb",
... )
>>> rel.aggregate("INSEE_REG, sum(POPULATION)")