felt / tippecanoe

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

Error Handling Mixed Geometry Types in FlatGeoBuf with tippecanoe #245

Open MichielMortier opened 1 month ago

MichielMortier commented 1 month ago

Summary

When converting GeoJSON files containing a mix of LineString and MultiLineString geometries to FlatGeoBuf format using ogr2ogr, tippecanoe fails to process the resulting FlatGeoBuf file.

Details

Problem Description:

I am encountering an issue when feeding FlatGeoBuf files that contain both LineString and MultiLineString geometries into tippecanoe. The conversion from GeoJSON to FlatGeoBuf using ogr2ogr completes successfully, but tippecanoe fails to process the resulting FlatGeoBuf file and returns the following error:

Error generating tiles: failed to generate mbtiles file: error executing command: exit status 106, For layer 0, using name "map_multifgb"
detected indexed FlatGeobuf: assigning feature IDs by sequence
flatgeobuf has unsupported geometry type 0

Example GeoJSON: The following GeoJSON content works directly with tippecanoe but fails after converting to FlatGeoBuf:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [[102, 0], [103, 1]]
      },
      "properties": {
        "name": "Example LineString 1"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "LineString",
        "coordinates": [[104, 0], [105, 1]]
      },
      "properties": {
        "name": "Example LineString 2"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [[[106, 0], [107, 1]], [[108, 0], [109, 1]]]
      },
      "properties": {
        "name": "Example MultiLineString 1"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [[[110, 0], [111, 1]], [[112, 0], [113, 1]]]
      },
      "properties": {
        "name": "Example MultiLineString 2"
      }
    }
  ]
}

Steps to Reproduce:

  1. Convert the above GeoJSON to FlatGeoBuf using ogr2ogr:
    ogr2ogr -f FlatGeobuf output.fgb input.geojson
  2. Attempt to process the resulting FlatGeoBuf file with tippecanoe:
    tippecanoe -o output.mbtiles output.fgb

Expected Behavior: tippecanoe should successfully process the FlatGeoBuf file and generate the corresponding MBTiles file.

Actual Behavior: tippecanoe returns the error:

Error generating tiles: failed to generate mbtiles file: error executing command: exit status 106, For layer 0, using name "map_multifgb"
detected indexed FlatGeobuf: assigning feature IDs by sequence
flatgeobuf has unsupported geometry type 0

Environment:

Additional Information: I suspect that the mix of LineString and MultiLineString geometries within the same FlatGeoBuf file might be causing the issue. Any guidance or suggestions on how to resolve this would be greatly appreciated.

Thanks!

KR Michiel

RizkiAlhamid commented 4 weeks ago

Hi, I've had the same issue for 3 weeks. The problem is with MultiLineString. I made a PR (#241) but unfortunately, there has been no response yet. For now, I just explode the MultiLineString into multiple LineStrings, but it can be really slow if your data has many big MultiLineStrings.