Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVT (directory-style) tiles not being generated when TILING_SCHEME for WorldCRS84Quad is specified #11749

Closed
ThorodanBrom opened this issue Jan 29, 2025 · 7 comments · Fixed by #11762
Assignees

Comments

@ThorodanBrom
Copy link

ThorodanBrom commented Jan 29, 2025

What is the bug?

Hello,

  • MVT tiles in a directory are not being generated when I specify the tiling scheme for the TMS WorldCRS84Quad in GDAL version 3.8.4 (and possibly above).
  • The directory is created with a metadata.json, but no zoom-level directories are present.
  • I tested it with GDAL 3.8.5 and the latest version 3.10.1 and it did not work
  • Other tiling scheme values like WebMercator (specified on the MVT docs page) generate tiles with both 3.8.5 and 3.10.1
  • However, generating tiles with the WorldCRS84Quad tiling scheme was working fine on GDAL version 3.4.1 and the tiles generated were valid and could be plotted

Steps to reproduce the issue

Reproducing error with GDAL 3.8.4, 3.10.1

Using GDAL 3.8.4 on Ubuntu, with this GeoJSON file, attempting to generating directory-style MVTs, uncompressed. The tiling scheme values specified corresponds to the TMS WorldCRS84Quad. I get a similar result with GDAL 3.8.5, 3.10.1

$ ogr2ogr --version
GDAL 3.8.4, released 2024/02/08
$ ogr2ogr -f MVT japan_mvt japan.geojson -dsco TILING_SCHEME="EPSG:4326,-180,90,180" -dsco COMPRESS=NO -dsco MAXZOOM=10 -progress --debug ON
GeoJSON: Detected layer of mixed-geometry type features.
GeoJSON: First pass: 31.39 %
GeoJSON: First pass: 62.77 %
GeoJSON: First pass: 94.16 %
GeoJSON: First pass: 100.00 %
GDAL: GDALOpen(japan.geojson, this=0x5d77ae373ff0) succeeds as GeoJSON.
GDAL: GDALDriver::Create(MVT,japan_mvt,0,0,0,Unknown,0x5d77ae672510)
MVT: Creating temporary database...
0...10...20...30...40...50...60...70...80...90...100 - done.
GDALVectorTranslate: 47 features written in layer 'japan'
GDAL: GDALClose(japan.geojson, this=0x5d77ae373ff0)
MVT: Building output file from temporary database...
GDAL: GDALClose(japan_mvt, this=0x5d77ae5ca5c0)
GDAL: In GDALDestroy - unloading GDAL shared library.
$ ls japan_mvt/
metadata.json
$ cat japan_mvt/metadata.json 
{
  "name":"japan_mvt",
  "description":"",
  "version":2,
  "minzoom":0,
  "maxzoom":10,
  "center":"138.4601795,32.9900357,0",
  "bounds":"122.9334931,20.4227403,153.9868658,45.5573311",
  "type":"overlay",
  "format":"pbf",
  "crs":"EPSG:4326",
  "tile_origin_upper_left_x":-180.0,
  "tile_origin_upper_left_y":90.0,
  "tile_dimension_zoom_0":180.0,
  "json":"{\n  \"vector_layers\":[],\n  \"tilestats\":{\n    \"layerCount\":0,\n    \"layers\":[]\n  }\n}"
}

Tiles generated as expected with GDAL 3.4.1

This was tested with the ghcr.io/osgeo/gdal:ubuntu-small-3.4.1 Docker image. I can confirm that the tiles generated by this are accurate when plotted on OpenLayers with the WorldCRS84Quad TMS.

$ ogr2ogr --version
GDAL 3.4.1, released 2021/12/27
$ ogr2ogr -f MVT japan_mvt japan.geojson -dsco TILING_SCHEME="EPSG:4326,-180,90,180" -dsco COMPRESS=NO -dsco MAXZOOM=10 -progress --debug ON
GeoJSON: Detected layer of mixed-geometry type features.
GeoJSON: First pass: 31.39 %
GeoJSON: First pass: 62.77 %
GeoJSON: First pass: 94.16 %
GeoJSON: First pass: 100.00 %
GDAL: GDALOpen(japan.geojson, this=0x5f7ae33c7d20) succeeds as GeoJSON.
GDAL: GDALDriver::Create(MVT,japan_mvt,0,0,0,Unknown,0x5f7ae34ad100)
MVT: Creating temporary database...
0...10...20...30...40...50...60...70...80...90...100 - done.
GDALVectorTranslate: 47 features written in layer 'japan'
GDAL: GDALClose(japan.geojson, this=0x5f7ae33c7d20)
MVT: Building output file from temporary database...
MVT: 10%...
MVT: 20%...
MVT: 30%...
MVT: 40%...
MVT: 50%...
MVT: 60%...
MVT: 70%...
MVT: 80%...
MVT: 90%...
MVT: 100%...
GDAL: GDALClose(japan_mvt, this=0x5f7ae34121c0)
GDAL: In GDALDestroy - unloading GDAL shared library.
$ ls japan_mvt/
0  1  10  2  3  4  5  6  7  8  9  metadata.json
$ cat japan_mvt/metadata.json 
{
  "name":"japan_mvt",
  "description":"",
  "version":2,
  "minzoom":0,
  "maxzoom":10,
  "center":"138.4601795,32.9900357,0",
  "bounds":"122.9334931,20.4227403,153.9868658,45.5573311",
  "type":"overlay",
  "format":"pbf",
  "crs":"EPSG:4326",
  "tile_origin_upper_left_x":-180.0,
  "tile_origin_upper_left_y":90.0,
  "tile_dimension_zoom_0":180.0,
  "json":"{\n  \"vector_layers\":[\n    {\n      \"id\":\"japan\",\n      \"description\":\"\",\n      \"minzoom\":0,\n      \"maxzoom\":10,\n      \"fields\":{\n        \"nam\":\"String\",\n        \"nam_ja\":\"String\",\n        \"id\":\"Number\"\n      }\n    }\n  ],\n  \"tilestats\":{\n    \"layerCount\":1,\n    \"layers\":[\n      {\n        \"layer\":\"japan\",\n        \"count\":47,\n        \"geometry\":\"Polygon\",\n        \"attributeCount\":3,\n        \"attributes\":[\n          {\n            \"attribute\":\"nam\",\n            \"count\":47,\n            \"type\":\"string\",\n            \"values\":[\n              \"Gifu Ken\",\n              \"Kyoto Fu\",\n              \"Mie Ken\",\n              \"Nara Ken\",\n              \"Oita Ken\",\n              \"Osaka Fu\",\n              \"Saga Ken\",\n              \"Tokyo To\",\n              \"Aichi Ken\",\n              \"Akita Ken\",\n              \"Aomori Ken\",\n              \"Chiba Ken\",\n              \"Ehime Ken\",\n              \"Fukui Ken\",\n              \"Fukuoka Ken\",\n              \"Fukushima Ken\",\n              \"Gunma Ken\",\n              \"Hiroshima Ken\",\n              \"Hokkai Do\",\n              \"Hyogo Ken\",\n              \"Ibaraki Ken\",\n              \"Ishikawa Ken\",\n              \"Iwate Ken\",\n              \"Kagawa Ken\",\n              \"Kagoshima Ken\",\n              \"Kanagawa Ken\",\n              \"Kochi Ken\",\n              \"Kumamoto Ken\",\n              \"Miyagi Ken\",\n              \"Miyazaki Ken\",\n              \"Nagano Ken\",\n              \"Nagasaki Ken\",\n              \"Niigata Ken\",\n              \"Okayama Ken\",\n              \"Okinawa Ken\",\n              \"Saitama Ken\",\n              \"Shiga Ken\",\n              \"Shimane Ken\",\n              \"Shizuoka Ken\",\n              \"Tochigi Ken\",\n              \"Tokushima Ken\",\n              \"Tottori Ken\",\n              \"Toyama Ken\",\n              \"Wakayama Ken\",\n              \"Yamagata Ken\",\n              \"Yamaguchi Ken\",\n              \"Yamanashi Ken\"\n            ]\n          },\n          {\n            \"attribute\":\"nam_ja\",\n            \"count\":47,\n            \"type\":\"string\",\n            \"values\":[\n              \"三重県\",\n              \"京都府\",\n              \"佐賀県\",\n              \"兵庫県\",\n              \"北海道\",\n              \"千葉県\",\n              \"和歌山県\",\n              \"埼玉県\",\n              \"大分県\",\n              \"大阪府\",\n              \"奈良県\",\n              \"宮城県\",\n              \"宮崎県\",\n              \"富山県\",\n              \"山口県\",\n              \"山形県\",\n              \"山梨県\",\n              \"岐阜県\",\n              \"岡山県\",\n              \"岩手県\",\n              \"島根県\",\n              \"広島県\",\n              \"徳島県\",\n              \"愛媛県\",\n              \"愛知県\",\n              \"新潟県\",\n              \"東京都\",\n              \"栃木県\",\n              \"沖縄県\",\n              \"滋賀県\",\n              \"熊本県\",\n              \"石川県\",\n              \"神奈川県\",\n              \"福井県\",\n              \"福岡県\",\n              \"福島県\",\n              \"秋田県\",\n              \"群馬県\",\n              \"茨城県\",\n              \"長崎県\",\n              \"長野県\",\n              \"青森県\",\n              \"静岡県\",\n              \"香川県\",\n              \"高知県\",\n              \"鳥取県\",\n              \"鹿児島県\"\n            ]\n          },\n          {\n            \"attribute\":\"id\",\n            \"count\":47,\n            \"type\":\"number\",\n            \"values\":[\n              1,\n              2,\n              3,\n              4,\n              5,\n              6,\n              7,\n              8,\n              9,\n              10,\n              11,\n              12,\n              13,\n              14,\n              15,\n              16,\n              17,\n              18,\n              19,\n              20,\n              21,\n              22,\n              23,\n              24,\n              25,\n              26,\n              27,\n              28,\n              29,\n              30,\n              31,\n              32,\n              33,\n              34,\n              35,\n              36,\n              37,\n              38,\n              39,\n              40,\n              41,\n              42,\n              43,\n              44,\n              45,\n              46,\n              47\n            ],\n            \"min\":1,\n            \"max\":47\n          }\n        ]\n      }\n    ]\n  }\n}"
}

Versions and provenance

Was able to reproduce on

  • GDAL 3.8.4 on Ubuntu 24.04 (installed using apt)
  • GDAL 3.8.5 on Docker image ghcr.io/osgeo/gdal:ubuntu-small-3.8.5
  • GDAL 3.10.1 on Docker image ghcr.io/osgeo/gdal:ubuntu-small-3.10.1

Additional context

I'm happy to provide any more information that's required. Thanks!

@jratike80
Copy link
Collaborator

jratike80 commented Jan 29, 2025

Feels like the driver awaits only one, square tile at zoom level 0.
The whole world example is using scheme "EPSG:4326,-180,180,360".

I do not know how to define matrix sizes of 1x2, 1x3, 1x4 etc with only 3 parameters tile_origin_upper_left_x,tile_origin_upper_left_y,tile_dimension_zoom_0
Could it help to express also the layer bounds BOUNDS=-180,-90,180,90?

@ThorodanBrom
Copy link
Author

Hello @jratike80, thanks for the response. I tried including the BOUNDS dataset creation option as you suggested, but it did not work. I tried with versions 3.8.4, 3.8.5 and 3.10.1 and I get the same result - no zoom-level folders and only metadata.json

$ ogr2ogr --version
GDAL 3.10.1, released 2025/01/08
$ ogr2ogr -f MVT japan_mvt japan.geojson -dsco TILING_SCHEME="EPSG:4326,-180,90,180" -dsco COMPRESS=NO -dsco MAXZOOM=10 -dsco BOUNDS=-180,-90,180,90 -progress --debug ON
GeoJSON: Detected layer of mixed-geometry type features.
GeoJSON: First pass: 31.39 %
GeoJSON: First pass: 62.77 %
GeoJSON: First pass: 94.16 %
GeoJSON: First pass: 100.00 %
GDAL: GDALOpen(japan.geojson, this=0x5c2e2d9b39b0) succeeds as GeoJSON.
GDAL: GDALDriver::Create(MVT,japan_mvt,0,0,0,Unknown,0x5c2e2dd51e00)
MVT: Creating temporary database...
0...10...20...30...40...50...60...70...80...90...100 - done.
GDALVectorTranslate: 47 features written in layer 'japan'
GDAL: GDALClose(japan.geojson, this=0x5c2e2d9b39b0)
MVT: Building output file from temporary database...
GDAL: GDALClose(japan_mvt, this=0x5c2e2dab4670)
GDAL: In GDALDestroy - unloading GDAL shared library.
$ ls japan_mvt/
metadata.json
$ cat japan_mvt/metadata.json 
{
  "name":"japan_mvt",
  "description":"",
  "version":2,
  "minzoom":0,
  "maxzoom":10,
  "center":"138.4601795,32.9900357,0",
  "bounds":"-180,-90,180,90",
  "type":"overlay",
  "format":"pbf",
  "crs":"EPSG:4326",
  "tile_origin_upper_left_x":-180.0,
  "tile_origin_upper_left_y":90.0,
  "tile_dimension_zoom_0":180.0,
  "json":"{\n  \"vector_layers\":[\n  ],\n  \"tilestats\":{\n    \"layerCount\":0,\n    \"layers\":[\n    ]\n  }\n}"
}

@ThorodanBrom
Copy link
Author

I also tried to determine which version of GDAL introduced this particular regression, it seems to be version 3.8.0. The version prior to that, 3.7.3, is able to generate tiles with the WorldCRS84Quad tiling scheme.

@ThorodanBrom
Copy link
Author

My colleague @DivyaSreeMunagavalasa and I tested this further - we found out that tiles are generated for features present on the western hemisphere - but not the eastern hemisphere. Most of the data that we deal with is located on the eastern hemisphere, so we didn't realise the issue (I don't know whether this is an issue anymore?) till we tried generating tiles for US states.

Using this GeoJSON file with GDAL 3.8.4, tiles are generated as expected. We can confirm that it also works with GDAL 3.10.1.

Is there any config option or extra dataset creation option that we can add to fix this?

$ ogr2ogr --version 
GDAL 3.8.4, released 2024/02/08
$ ogr2ogr -f MVT USA us-states.json -dsco TILING_SCHEME="EPSG:4326,-180,90,180" -dsco COMPRESS=NO -dsco MAXZOOM=10 -progress --debug ON 
GeoJSON: Detected layer of mixed-geometry type features.
GeoJSON: First pass: 100.00 %
GDAL: GDALOpen(us-states.json, this=0x596085a77ff0) succeeds as GeoJSON.
GDAL: GDALDriver::Create(MVT,USA,0,0,0,Unknown,0x596085d7dcc0)
MVT: Creating temporary database...
0...10...20...30...40...50...60...70...80...90...100 - done.
GDALVectorTranslate: 52 features written in layer 'us-states'
GDAL: GDALClose(us-states.json, this=0x596085a77ff0)
MVT: Building output file from temporary database...
MVT: 10%...
MVT: 20%...
MVT: 30%...
MVT: 40%...
MVT: 50%...
MVT: 60%...
MVT: 70%...
MVT: 80%...
MVT: 90%...
MVT: 100%...
GDAL: GDALClose(USA, this=0x596085aa55c0)
GDAL: In GDALDestroy - unloading GDAL shared library.
$ ls USA/
0  1  10  2  3  4  5  6  7  8  9  metadata.json
$ cat USA/metadata.json 
{
  "name":"USA",
  "description":"",
  "version":2,
  "minzoom":0,
  "maxzoom":10,
  "center":"-127.2658535,44.6405945,0",
  "bounds":"-188.9049100,17.9295560,-65.6267970,71.3516330",
  "type":"overlay",
  "format":"pbf",
  "crs":"EPSG:4326",
  "tile_origin_upper_left_x":-180.0,
  "tile_origin_upper_left_y":90.0,
  "tile_dimension_zoom_0":180.0,
  "json":"{\n  \"vector_layers\":[\n    {\n      \"id\":\"us-states\",\n      \"description\":\"\",\n      \"minzoom\":0,\n      \"maxzoom\":10,\n      \"fields\":{\n        \"id\":\"String\",\n        \"name\":\"String\",\n        \"density\":\"Number\"\n      }\n    }\n  ],\n  \"tilestats\":{\n    \"layerCount\":1,\n    \"layers\":[\n      {\n        \"layer\":\"us-states\",\n        \"count\":52,\n        \"geometry\":\"Polygon\",\n        \"attributeCount\":3,\n        \"attributes\":[\n          {\n            \"attribute\":\"id\",\n            \"count\":52,\n            \"type\":\"string\",\n            \"values\":[\n              \"01\",\n              \"02\",\n              \"04\",\n              \"05\",\n              \"06\",\n              \"08\",\n              \"09\",\n              \"10\",\n              \"11\",\n              \"12\",\n              \"13\",\n              \"15\",\n              \"16\",\n              \"17\",\n              \"18\",\n              \"19\",\n              \"20\",\n              \"21\",\n              \"22\",\n              \"23\",\n              \"24\",\n              \"25\",\n              \"26\",\n              \"27\",\n              \"28\",\n              \"29\",\n              \"30\",\n              \"31\",\n              \"32\",\n              \"33\",\n              \"34\",\n              \"35\",\n              \"36\",\n              \"37\",\n              \"38\",\n              \"39\",\n              \"40\",\n              \"41\",\n              \"42\",\n              \"44\",\n              \"45\",\n              \"46\",\n              \"47\",\n              \"48\",\n              \"49\",\n              \"50\",\n              \"51\",\n              \"53\",\n              \"54\",\n              \"55\",\n              \"56\",\n              \"72\"\n            ]\n          },\n          {\n            \"attribute\":\"name\",\n            \"count\":52,\n            \"type\":\"string\",\n            \"values\":[\n              \"Alabama\",\n              \"Alaska\",\n              \"Arizona\",\n              \"Arkansas\",\n              \"Colorado\",\n              \"Delaware\",\n              \"Florida\",\n              \"Georgia\",\n              \"Hawaii\",\n              \"Idaho\",\n              \"Illinois\",\n              \"Indiana\",\n              \"Iowa\",\n              \"Kansas\",\n              \"Kentucky\",\n              \"Maine\",\n              \"Maryland\",\n              \"Michigan\",\n              \"Missouri\",\n              \"Montana\",\n              \"Nebraska\",\n              \"Nevada\",\n              \"New York\",\n              \"Ohio\",\n              \"Oklahoma\",\n              \"Oregon\",\n              \"Texas\",\n              \"Utah\",\n              \"Vermont\",\n              \"Virginia\",\n              \"Wyoming\",\n              \"California\",\n              \"Connecticut\",\n              \"District of Columbia\",\n              \"Louisiana\",\n              \"Massachusetts\",\n              \"Minnesota\",\n              \"Mississippi\",\n              \"New Hampshire\",\n              \"New Jersey\",\n              \"New Mexico\",\n              \"North Carolina\",\n              \"North Dakota\",\n              \"Pennsylvania\",\n              \"Puerto Rico\",\n              \"Rhode Island\",\n              \"South Carolina\",\n              \"South Dakota\",\n              \"Tennessee\",\n              \"Washington\",\n              \"West Virginia\",\n              \"Wisconsin\"\n            ]\n          },\n          {\n            \"attribute\":\"density\",\n            \"count\":51,\n            \"type\":\"number\",\n            \"values\":[\n              1.264,\n              5.851,\n              6.8579999999999997,\n              9.9160000000000004,\n              17.16,\n              19.149999999999999,\n              23.969999999999999,\n              24.800000000000001,\n              34.299999999999997,\n              35.090000000000003,\n              40.329999999999998,\n              43.039999999999999,\n              49.329999999999998,\n              54.810000000000002,\n              55.219999999999999,\n              56.43,\n              57.049999999999997,\n              63.5,\n              67.140000000000001,\n              67.730000000000004,\n              77.060000000000002,\n              87.260000000000005,\n              88.079999999999998,\n              94.650000000000006,\n              98.069999999999993,\n              102.59999999999999,\n              105.0,\n              105.2,\n              110.0,\n              147.0,\n              155.40000000000001,\n              169.5,\n              173.90000000000001,\n              181.69999999999999,\n              198.19999999999999,\n              204.5,\n              214.09999999999999,\n              231.5,\n              241.69999999999999,\n              281.89999999999998,\n              284.30000000000001,\n              353.39999999999998,\n              412.30000000000001,\n              464.30000000000001,\n              596.29999999999995,\n              739.10000000000002,\n              840.20000000000005,\n              1006.0,\n              1082.0,\n              1189.0,\n              10065.0\n            ],\n            \"min\":1.264,\n            \"max\":10065.0\n          }\n        ]\n      }\n    ]\n  }\n}"
}

@rouault rouault self-assigned this Jan 30, 2025
@jratike80
Copy link
Collaborator

we found out that tiles are generated for features present on the western hemisphere - but not the eastern hemisphere.

That is what I meant by "Feels like the driver awaits only one, square tile at zoom level 0."
In your case, the GDAL logic is probably "the top-left of the tile 0 is at -180, 90, and the one and only tile ends 180 east from -180, thus at longitude of 0 degrees".

@rouault
Copy link
Member

rouault commented Jan 30, 2025

Fix in #11762. There isn't any workaround I can think of

@ThorodanBrom
Copy link
Author

@jratike80 thanks for explaining your previous comment, I now understand the issue.

@rouault thanks for the bug fix. We'll use the latest version that contains the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants