Public
Edited
Sep 4, 2023
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
topohelper
// direct call inside from() to avoid a deep copy
.from(
await bdr_13
)
//.project({ proj: l93 })
.view({ tooltip: true, zoom: true })
Insert cell
Insert cell
Insert cell
map_departement = topohelper
// direct call inside from() to avoid a deep copy
.from(
await df
)
//.project({ proj: l93 })
.view({ tooltip: true, zoom: true })
Insert cell
Insert cell
Insert cell
Insert cell
bdr_13 = FileAttachment("13@1.topojson").json()
Insert cell
Inputs.table(
bertin.properties.table(geojson_13)
)
Insert cell
Inputs.table(
bdr_13.objects["13"].geometries.map(l => l.properties)
)
Insert cell
geojson_13 = d3.json("https://minio.lab.sspcloud.fr/projet-cartiflette/diffusion/shapefiles-test2/year=2022/administrative_level=COMMUNE/crs=4326/DEPARTEMENT=13/vectorfile_format=geojson/provider=IGN/source=EXPRESS-COG-CARTO-TERRITOIRE/raw.geojson")
Insert cell
url_france_by_dep = "https://minio.lab.sspcloud.fr/lgaliana/diffusion/COMMUNE_DEPARTEMENT.topojson"
Insert cell
data_france = d3.json(url_france_by_dep)
Insert cell
## Annexe: travail préparatoire
Insert cell
### Python

```python
import requests
import os
import py7zr

url = "https://wxs.ign.fr/x02uy2aiwjo9bm8ce5plwqmr/telechargement/prepackage/ADMINEXPRESS-COG-CARTO_SHP_TERRITOIRES_PACK_2023-05-04$ADMIN-EXPRESS-COG-CARTO_3-2__SHP_LAMB93_FXX_2023-05-03/file/ADMIN-EXPRESS-COG-CARTO_3-2__SHP_LAMB93_FXX_2023-05-03.7z"

response = requests.get(url, stream = True)

with open("data.7z", "wb") as f:
f.write(response.content)

with py7zr.SevenZipFile('data.7z', mode='r') as z:
z.extractall()

def file_size(file_name):
file_stats = os.stat(file_name)
return f'File Size in MegaBytes is {file_stats.st_size / (1024 * 1024)}'
```

### CLI mapshaper

```python
sudo apt-get update
sudo apt install npm nodejs

git clone https://github.com/mbloch/mapshaper.git
cd mapshaper
npm install # install dependencies
npm run build # bundle source code files
sudo npm link # (optional) add global symlinks so scripts are available systemwide


mapshaper ADMIN-EXPRESS-COG-CARTO_3-2__SHP_LAMB93_FXX_2023-05-03/ADMIN-EXPRESS-COG-CARTO/1_DONNEES_LIVRAISON_2023-05-03/ADECOGC_3-2_SHP_LAMB93_FXX/COMMUNE.shp -filter '"69123,13055,75056".indexOf(INSEE_COM) > -1' invert -o out_cities.topojson
mapshaper ADMIN-EXPRESS-COG-CARTO_3-2__SHP_LAMB93_FXX_2023-05-03/ADMIN-EXPRESS-COG-CARTO/1_DONNEES_LIVRAISON_2023-05-03/ADECOGC_3-2_SHP_LAMB93_FXX/ARRONDISSEMENT_MUNICIPAL.shp -simplify 60% -o out_arrondissement.topojson

mapshaper out_cities.topojson out_arrondissement.topojson combine-files -merge-layers target=COMMUNE,ARRONDISSEMENT_MUNICIPAL force -rename-layers COMMUNE_ARRONDISSEMENT -simplify 60% -o test.topojson -proj from=wgs84


mapshaper ADMIN-EXPRESS-COG-CARTO_3-2__SHP_LAMB93_FXX_2023-05-03/ADMIN-EXPRESS-COG-CARTO/1_DONNEES_LIVRAISON_2023-05-03/ADECOGC_3-2_SHP_LAMB93_FXX/COMMUNE.shp name='' -split INSEE_REG -o 'regions/' format=geojson
```
Insert cell
Insert cell
Inputs.table(
df.objects.COMMUNE_ARRONDISSEMENT.geometries.map(l => l.properties).filter(d => d.INSEE_DEP =="13")
)
Insert cell
old_geojson = d3.json("https://minio.lab.sspcloud.fr/projet-cartiflette/diffusion/shapefiles-test2/year=2022/administrative_level=COMMUNE_ARRONDISSEMENT/crs=4326/DEPARTEMENT=13/vectorfile_format=geojson/provider=IGN/source=EXPRESS-COG-CARTO-TERRITOIRE/raw.geojson")
Insert cell
Inputs.table(
bertin.properties.table(old_geojson)
)
Insert cell
bertin = require("bertin@latest")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more