'Create multiple layers from single geojson using Tippecanoe
I have a geojson file, small4326.geojson:
{
"type": "FeatureCollection",
"name": "out",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "layer": "layer0" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.547599967297632, 69.059954062460378 ], [ 20.54757733048131, 69.059864800710685 ], [ 20.548575503457567, 69.059832409196858 ], [ 20.54859814429587, 69.059921670795845 ], [ 20.547599967297632, 69.059954062460378 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer0" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.548575503457567, 69.059832409196858 ], [ 20.548552862816955, 69.059743147593522 ], [ 20.548802404561339, 69.059735048846079 ], [ 20.548825046207433, 69.05982431041177 ], [ 20.548575503457567, 69.059832409196858 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer1" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.54505925764245, 69.059856491978053 ], [ 20.54501400510787, 69.059677967703394 ], [ 20.545263547608076, 69.05966987410855 ], [ 20.545308802153656, 69.059848398307878 ], [ 20.54505925764245, 69.059856491978053 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer1" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.548507582128785, 69.059564624373721 ], [ 20.548484942081224, 69.059475362757269 ], [ 20.54873448080922, 69.059467264122915 ], [ 20.548757121862234, 69.059556525701666 ], [ 20.548507582128785, 69.059564624373721 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer2" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.539750962125389, 69.059758586485131 ], [ 20.53972835746767, 69.059669323546402 ], [ 20.540227446542453, 69.059653151376537 ], [ 20.540250053211235, 69.059742414240006 ], [ 20.539750962125389, 69.059758586485131 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer6" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.547464149364455, 69.059418491896636 ], [ 20.547441513734022, 69.059329230120753 ], [ 20.547691051241777, 69.059321133012361 ], [ 20.547713687877661, 69.059410394750572 ], [ 20.547464149364455, 69.059418491896636 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer8" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.541702096524656, 69.05951536352093 ], [ 20.541679484217624, 69.059426100874532 ], [ 20.5419290252634, 69.059418012144889 ], [ 20.541951638575927, 69.059507274753642 ], [ 20.541702096524656, 69.05951536352093 ] ] ] } },
{ "type": "Feature", "properties": { "layer": "layer9" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 20.542927187471967, 69.059385653599719 ], [ 20.542904570334962, 69.059296391137195 ], [ 20.543154109387942, 69.059288300631877 ], [ 20.543176727530422, 69.059377563056771 ], [ 20.542927187471967, 69.059385653599719 ] ] ] } }
]
}
I am using this file to produce .pbf tiles using Tippecanoe. Within each feature's property there is the layer field, specifying which layer I want the given feature to be.
Currently, if I do:
tippecanoe -Z 10 -z 13 -e restiles --force small4326.geojson --no-tile-compression
I get as output:
For layer 0, using name "small4326"
8 features, 214 bytes of geometry, 8 bytes of separate metadata, 36 bytes of string pool
99.6% 13/4563/1894
As expected, all features go to a single layer. I would like to have the first two Features go into a layer called layer0, the second pair to layer1, and so on, each Feature to the layer specified by the layer field of the given Feature:
I prefer not to separate the file into separate geojsons, because in my real world application, it is huge, and I cannot handle it using standard tools like jq without running out of memory.
How can I tell Tippecanoe to create separate layers, and place each Feature to the layer specified in the layer field in its properties?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

