Error: Input data is not a valid GeoJSON object
Dutisto opened this issue · 4 comments
Hi,
I'm trying to use this tool but I always get that error : Error: Input data is not a valid GeoJSON object
I've tested with multiples geojson, and some from http://geojson.io . Nothing seems to work out.
I'm using the same code as in the README.md :
// build an initial index of tiles
var tileIndex = geojsonvt(geoJSON);
// request a particular tile
var features = tileIndex.getTile(z, x, y).features;
// show an array of tile coordinates created so far
console.log(tileIndex.tileCoords); // [{z: 0, x: 0, y: 0}, ...]
Any advices ?
Try putting your GeoJSON into http://geojsonlint.com/ and seeing if it has any problems.
I'm trying to use a very simple geojson, verified on geojsonlint.com :
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
1.8017578124999998,
50.68949806239989
],
[
1.64794921875,
50.72341622356851
],
[
1.7509460449218748,
50.4758608877373
],
[
2.335968017578125,
50.34370762530209
],
[
1.902008056640625,
50.566666077402395
],
[
2.13958740234375,
50.59805794433924
],
[
2.088775634765625,
50.73037076236953
],
[
1.8017578124999998,
50.68949806239989
]
]
]
}
}
]
}
The content of my main.js :
var geojsonvt = require('geojson-vt');
var fs = require("fs");
var content = fs.readFileSync("miss.geojson").toString();
// build an initial index of tiles
var tileIndex = geojsonvt(content);
// request a particular tile
var features = tileIndex.getTile(19, 50.611103, 2.96086).features;
// show an array of tile coordinates created so far
console.log(tileIndex.tileCoords); // [{z: 0, x: 0, y: 0}, ...]
And still the same error
@Dutisto you're passing a string to geojsonvt
, and it expects a JSON object. You should do geojsonvt(JSON.parse(content))
.
Oh, so that's really a dumb mistake. Thanks for the help !