mapbox / tilesets-cli

CLI for interacting with the Mapbox Tilesets API and Mapbox Tiling Service
https://docs.mapbox.com/mapbox-tiling-service
BSD 2-Clause "Simplified" License
125 stars 27 forks source link

`tilesets publish` returning "No GeoJSON features processed. Make sure your GeoJSON is line-delimited." #155

Closed maxmiranda closed 2 years ago

maxmiranda commented 2 years ago

Following the tutorial here https://docs.mapbox.com/help/tutorials/get-started-mts-and-tilesets-cli to try to upload my GEOJson file to a tileset.

Ran the following commands to get this output:

  1. tilesets validate-source cupertino.geojson
    • Output: Validating features ✔ valid
  2. tilesets upload-source maxmiranda cardio-grid cupertino.geojson
    • Output: {"id": "mapbox://tileset-source/maxmiranda/cardio-grid", "files": 1, "source_size": 743104, "file_size": 743104}
  3. tilesets create maxmiranda.cardio-grid-tiles --recipe cardio-grid-recipe.json --name "cardio grid"
    • My Recipe:
      {
      "version": 1,
      "layers": {
      "grid": {
      "source": "mapbox://tileset-source/maxmiranda/cardio-grid",
      "minzoom": 0,
      "maxzoom": 5
      }
      }
      }
    • Output:
{"message": "Successfully created empty tileset maxmiranda.cardio-grid-tiles. Publish your tileset to begin processing your data into vector tiles."}
  1. tilesets publish maxmiranda.cardio-grid-tiles

{"message": "Processing maxmiranda.cardio-grid-tiles", "jobId": "cl275u142000309mr24uqgf7m"}

✔ Tileset job received. Visit https://studio.mapbox.com/tilesets/maxmiranda.cardio-grid-tiles or run tilesets job maxmiranda.cardio-grid-tiles cl275u142000309mr24uqgf7m to view the status of your tileset.


**I even tried to convert my geojson file to geojson.ld before uploading it as a source. However, this did not work either and the same error was returned. Please let me know what I have to do to convert this geojson successfully into a tileset.**
<details>
<summary> Snippet from my GEOJson file (which i've tested by directly adding a source to my map) </summary>

{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "coordinates": [ [ [ -122.09381103515625, 37.34177550214858 ], [ -122.09381103515625, 37.34068368469043 ], [ -122.09243774414062, 37.34068368469043 ], [ -122.09243774414062, 37.34177550214858 ] ] ], "type": "Polygon" } },



</details>
e-n-f commented 2 years ago

I no longer work at Mapbox, but the problem is probably that your polygons are too small to be visible in z5 tiles. It looks like this one is about 400 feet tall, but z5 has a precision of about 1000 feet at best. The same polygon processed with tippecanoe does not show up until zoom level 8.

maxmiranda commented 2 years ago

Thank you for the advice @e-n-f, per your suggestion, I tried modifying recipe to increase minzoom to 14 and maxzoom to maximum (16). Unfortunately, got the exact same error even after I confirmed recipe got updated properly. Note that each of the polygons I'm trying to plot are the tiles that are rendered at zoom level 18 (photo attached). Any other guidance on why this might not be working?

image

e-n-f commented 2 years ago

It looks like the problem may be that your polygons are not closed. A GeoJSON polygon representing a square is supposed to include five coordinate pairs, with the first coordinate pair duplicated as the last coordinate pair. Yours only have four coordinate pairs, all unique, so MTS is probably rejecting the geometry as invalid.

https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6

3.1.6.  Polygon

   To specify a constraint specific to Polygons, it is useful to
   introduce the concept of a linear ring:

   o  A linear ring is a closed LineString with four or more positions.

   o  The first and last positions are equivalent, and they MUST contain
      identical values; their representation SHOULD also be identical.
maxmiranda commented 2 years ago

@e-n-f THANK YOU SO MUCH!!! that's exactly right, I appreciate your quick response times & if anyone who currently works on Tilesets CLI sees this, I would recommend adding a similar check to the validation for uploading source files if that's indeed going to be required when processing the source!

mapsam commented 2 years ago

Thanks @e-n-f @maxmiranda for the help and conversation here! I'm commenting here to remind myself that we should consider using the official geojson schema for validation, instead of our own written jsonschema document https://github.com/geojson/schema

This at least enforces a minimum number of LinearRingCoordinates. It doesn't exactly check the first and last values are matching, but we'd improve the validation logic a little by moving this way.