mapbox / tippecanoe

Build vector tilesets from large collections of GeoJSON features.
BSD 2-Clause "Simplified" License
2.71k stars 430 forks source link

Points only #948

Open gguandf opened 1 year ago

gguandf commented 1 year ago

First - thanks for this powerful library.

I'm trying to create an mbtile-file with tippecanoe. The base is a geojson with 64800 points. Each point has coordinates and a value.

like:

{ "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 6.0, -89.5 ] }, "properties": { "value": -53.0 } },

Question 1: can this work? Question2: can tippecanoe deal with points only?

The problem: When the mbtile-file is loaded into SQLite-Viewer, metadata and tiles (binary) are shown but no images!? It is similar with tileserver-php-master - no images are loaded.

Any ideas what i'm doing wrong? The goal is to show all GeoJson points in a leaflet map. But with tiles which are loaded when zooming and scrolling - and not with one giant geojsons file.

e-n-f commented 1 year ago

Thanks! Tippecanoe development is now taking place in https://github.com/felt/tippecanoe.

Features like these should work with Tippecanoe. Tippecanoe can deal with points, LineStrings, and Polygons.

Tippecanoe creates vector tiles; it is necessary to use a renderer to see the output as images. You can for instance use Protomaps or Mapbox GL.

gguandf commented 1 year ago

Hi, thanks for your answer.

I'm wondering how to display the *.mbtiles-files in a leaflet-map. I allready tried TileLayer.MBTiles.js!

If I view the *.mbtiles-file in SQLite Viewer the format is 'pbf' !?! My leaflet-map is empty (in each zoom-level) - only the background-map (osm) is shown.

No JS-errors are returned.

kind regards.

e-n-f commented 1 year ago

I am no expert on Leaflet, but apparently there is a plugin to display vector tiles.

The "pbf" refers to the format defined here, which is based upon Protocol Buffers.

gguandf commented 1 year ago

Hello Erica, thanks again.

You steered me in the right direction!

With 'Leaflet.VectorGrid.bundled.js' and Tile-Sever now I can display the *.mbtiles as '{z}/{x}/{y}.pbf' on my leaflet-map.

Now I have to style the vector tiles - this can be done with the 'vectorTileLayerStyles' option. I.e. each layer can have its own style variants.

The goal is an mbtiles file with several layers. Is this possible with tippecanoe?

Kind regards.

e-n-f commented 1 year ago

Yes, if you supply multiple .json source files, each will be placed in its own layer, or you can use the -L option to associate sources with layers, or you can use the "tippecanoe": { "layer": name } field in a feature to specify its layer.

gguandf commented 1 year ago

OK. I understand that I can put different JSON source files in different layers. But can I only use one JSON file and assign different layer names based on the attribute (property) value?

eg: Values from 4 to 8 Layer-Name-X Values from 8 to 12 Layer-Name-Y

eg.

{
   "type": "FeatureCollection",
   "features": [
     {
       "type": "feature",
       "geometry": {
         "type": "Point",
         "coordinates": [
           150.0,
           90.0
         ]
       },
       "properties": {
         "value": 8.0
       }
     },
     {
       "type": "feature",
       "geometry": {
         "type": "Point",
         "coordinates": [
           151.0,
           90.0
         ]
       },
       "properties": {
         "value": 10.0
       }
     }
]
e-n-f commented 1 year ago

Tippecanoe does not have the ability to filter layers by attribute value. You would have do something like:

{"type":"Feature","tippecanoe":{"layer":"one"},"geometry":{"type":"Point","coordinates":[150,45]},"properties":{"value":8}}
{"type":"Feature","tippecanoe":{"layer":"two"},"geometry":{"type":"Point","coordinates":[151,45]},"properties":{"value":10}}

to explicitly tag each feature with its layer.

gguandf commented 1 year ago

Thanks again! I already found the layer-solution you mentioned in your last answer! great!

Hopefully my last problem/question:

I use this tippicanoe command to create mbtiles: tippecanoe --force -o 05/05.mbtiles --minimum-zoom=4 --maximum-zoom=9 --drop-densest-as-needed -rg 05/05.geojson

But when I inspect (with the SQLite browser) the mbtiles file, the metadata.generator_options says: tippecanoe --force -o 05/05.mbtiles '--minimum-zoom=4' '--maximum-zoom=9' --drop-densest-as-needed -rg 05/05.geojson

Please note the quotation marks at minimum and maximum!!!

These quotes are the problem! My TileServer says the mbtiles file is not well-formed - because of the quotes.

Do you have any idea? What does the tippecanoe command have to look like to get a valid mbtiles file?

e-n-f commented 1 year ago

I wrote the latest revision of the mbtiles spec, so I think TileServer is wrong, not tippecanoe, but if it doesn't like the generator_options, you can comment out this block of code and not include it in the metadata:

https://github.com/felt/tippecanoe/blob/182093bdc78d0a0adc65d24c9cbbe93eecaa38cf/mbtiles.cpp#L450-L457