I'm trying to create summary census statistics at different zoom levels for a state in the USA (census block group, tract, county and state), and I've found that the total population results generated with aggregation based on unions and a concatenated key using state,county,track census block group - that depends on zoom level can be incorrect if I set the zoom levels to low for e.g. census block group level (i.e. want to show more detail at lower zoom levels)
e.g. testing this recipe below for Rhode Island. Gave me a total population of 343,405 for the state instead of the correct number of 1,097,379 - which I've double checked is correct. There were no errors shown in the tile service after using the tilesets API to upload. If I change the zoom levels to e.g.
>= 0 for STATEFO
>= 5 for COUNTYFP
>= 8 for TRACTCE
>= 10 for BLKGRPCE
then the total population for the state is changed to the correct value 1,097,379. What am I missing here - how can data in the geojson dataset just get ignored?
Thanks David
{
"version": 1,
"layers": {
"NAME": {
"source": SOURCE,
"minzoom": 0,
"maxzoom": 10,
"features": {
"simplification": {
"outward_only": true,
"distance": 1
},
"attributes": {
"set": {
"key": [
"concat",
[
"case",
[
">=",
[
"zoom"
],
0
],
[
"get",
"STATEFP"
],
""
],
[
"case",
[
">=",
[
"zoom"
],
3
],
[
"get",
"COUNTYFP"
],
""
],
[
"case",
[
">=",
[
"zoom"
],
5
],
[
"get",
"TRACTCE"
],
""
],
[
"case",
[
">=",
[
"zoom"
],
8
],
[
"get",
"BLKGRPCE"
],
""
]
]
},
"allowed_output": ["tpop","STATEFP","COUNTYFP","TRACTCE","BLKGRPCE"]
}
},
"tiles": {
"union": [
{
"group_by": [
"key"
],
"aggregate": {
"tpop": "sum"
},
"simplification": {
"distance": 4,
"outward_only": false
}
}
],
"layer_size": 2500
}
}
}
}