-
Notifications
You must be signed in to change notification settings - Fork 54
How to generate the limits files
All files can be generated, starting from the original comuni.geojson
,
or another similar in format, produced by you.
The file is kept in the root directory, to avoid accidental removal.
Aggregate layers are generated from this file, by dissolving the areas having a common provincial or regional code.
As a prerequisite, install the mapshaper client
The comuni.geojson
file is a geojson file (one layer), produced out of the OPDM database, so that the following metadata are exported, along with the
geographic coordinates:
-
name
- the name of the municipality -
com_catasto_code
- the cadraste code (H501) -
com_istat_code
- the ISTAT code, as text (zero-padded) -
com_istat_code_num
- the ISTAT code, as integer -
op_id
- the openpolis ID (for integration with legacy OP data) -
opdm_id
- the opdm ID (for integration with OPDM data) -
minint_elettorale
- interior minister ID -
prov_name
- parent province name -
prov_istat_code
- parent province ISTAT code, as text (zero-padded) -
prov_istat_code_num
- parent province ISTAT code, as integer -
prov_acr
- parent province acronym (ex: RM) -
reg_name
- parent region full name -
reg_istat_code
- parent region ISTAT code, as text (zero padded) -
reg_istat_code_num
- parent region ISTAT code, as number
This section describes how to generate the topojson
files.
The following command will transform the original file into topojson
,
with a simplification of 5%, and retaining all the meta information.
mapshaper\
-i comuni.geojson -clean encoding=utf8 \
-simplify 5% weighted \
-o topojson/limits_IT_municipalities.topo.json bbox format=topojson
Increase the percentage to increase limits precision (and size, accordingly).
This will generate a single file containing three layers (comuni, province, regioni), plus two layers with provinces and regions.
mapshaper \
-i topojson/limits_IT_municipalities.topo.json -clean encoding=utf8 \
-rename-layers municipalities \
-dissolve prov_istat_code + \
copy-fields=prov_name,prov_istat_code_num,prov_acr,reg_name,reg_istat_code,reg_istat_code_num name=provinces \
-target 1 \
-dissolve reg_istat_code + \
copy-fields=reg_name,reg_istat_code_num name=regions \
-target 1 \
-o topojson/limits_IT_all.topo.json bbox format=topojson target=regions,provinces,municipalities \
-o topojson/limits_IT_regions.topo.json bbox format=topojson target=regions \
-o topojson/limits_IT_provinces.topo.json bbox format=topojson target=provinces
for REG in `seq 1 20`
do
mapshaper\
-i topojson/limits_IT_municipalities.topo.json \
-filter reg_istat_code_num==$REG \
-o topojson/limits_R_${REG}_municipalities.topo.json bbox format=topojson
done
for PROV in `seq 1 111`
do
mapshaper\
-i topojson/limits_IT_municipalities.topo.json \
-filter prov_istat_code_num==$PROV \
-rename-layers municipalities target=1 \
-o topojson/limits_P_${PROV}_municipalities.topo.json bbox format=topojson
done
This section describes how to generate the geojson
files.
cp comuni.geojson geojson/limits_IT_municipalities.geojson
mapshaper \
-i geojson/limits_IT_municipalities.geojson -clean encoding=utf8 \
-rename-layers municipalities \
-dissolve prov_istat_code + \
copy-fields=prov_name,prov_istat_code_num,prov_acr,reg_name,reg_istat_code,reg_istat_code_num name=provinces \
-target 1 \
-dissolve reg_istat_code + \
copy-fields=reg_name,reg_istat_code_num name=regions \
-target 1 \
-o geojson/limits_IT_provinces.geojson bbox format=geojson target=provinces \
-o geojson/limits_IT_regions.geojson bbox format=geojson target=regions
for REG in `seq 1 20`
do
mapshaper \
-i geojson/limits_IT_municipalities.geojson -clean encoding=utf8 \
-filter reg_istat_code_num==$REG \
-o geojson/limits_R_${REG}_municipalities.geojson bbox format=geojson
done
for PROV in `seq 1 111`
do
mapshaper \
-i geojson/limits_IT_municipalities.geojson -clean encoding=utf8 \
-filter prov_istat_code_num==$PROV \
-o geojson/limits_P_${PROV}_municipalities.geojson bbox format=geojson
done