I'm new to Mapbox tile-reduce library. I would like to process OSM tiles for Portugal.
I've download the mbtiles from Portugal.
I've installed tile-reduce
with:
npm ini
npm install @mapbox/tile-reduce
I've downloaded the tile-reduce/examples/count/
example.
My index.js
is:
'use strict';
var tileReduce = require('@mapbox/tile-reduce');
var path = require('path');
var numFeatures = 0;
tileReduce({
zoom: 12,
map: path.join(__dirname, '/count.js'),
sources: [{name: 'portugal', mbtiles: path.join(__dirname, 'portugal.mbtiles'), raw: true}]
})
.on('reduce', function (num) {
numFeatures += num;
})
.on('end', function () {
console.log('Features total: %d', numFeatures);
});
My count.js
is:
'use strict';
module.exports = function(data, tile, writeData, done) {
var count = 0;
if (data.portugal.roads) count += data.portugal.roads.length;
if (data.portugal.buildings) count += data.portugal.buildings.length;
done(null, count);
};
I was expecting to have the number of roads and buildings on the output, but the result is 0 features.
jgr@dusseldorf:/media/bonn/mapbox$ node index.js
Starting up 8 workers... Job started.
Processing tile coords from "portugal" source.
1876 tiles processed in 1s.
Features total: 0
What am I doing wrong?