I'm trying to identify the source of a problem that I'm having, I cannot show a tile layer(created with gdal2tiles) inside a polygon generated in Leaflet, using the plug-in BoundaryCanvas(https://github.com/aparshin/leaflet-boundary-canvas)

Some facts:

  • The tile layer created with Gdal2tiles.py, can be shown in the map with Leaflet if I just use the object tileLayer. From this I understand that the tile layer was generated correctly.

  • If I use the object tileLayer.BoundaryCanvas(with boundary a polygon), the tile is not shown and in the browser there are errors missing PNG files(it's trying to download png's that are not in the path structure of the tile layer).

  • If I use the same plug-in with for example the TMS from OSM http://{s}.tile.osm.org/{z}/{x}/{y}.png, it works properly I can show that tile inside the polygon.

At this point I don't know if the errors comes from the Leaflet plug-in or from the tile layer generation.

I'm using:

gdal2tiles.py --profile=geodetic -z 0-15 -w none ./terra.tif


Driver: GTiff/GeoTIFF

Files: TerraColor_SanFrancisco_US_15m.tif

Size is 7204 x 7204

Coordinate System is:

SPHEROID["WGS 84",6378137,298.257223563,

Origin = (-122.809804036593036,38.285436652047451)
Pixel Size = (0.000138800000000,-0.000138800000000)



Image Structure Metadata:


Corner Coordinates:

Upper Left  (-122.8098040, 38.2854367) (122d48'35.29"W, 38d17' 7.57"N)
Lower Left  (-122.8098040, 37.2855215) (122d48'35.29"W, 37d17' 7.88"N)
Upper Right (-121.8098888, 38.2854367) (121d48'35.60"W, 38d17' 7.57"N)
Lower Right (-121.8098888, 37.2855215) (121d48'35.60"W, 37d17' 7.88"N)
Center      (-122.3098464,  37.7854791) (122d18'35.45"W, 37d47' 7.72"N)
Band 1 Block=7204x1 Type=Byte, ColorInterp=Red
Band 2 Block=7204x1 Type=Byte, ColorInterp=Green
Band 3 Block=7204x1 Type=Byte, ColorInterp=Blue

1 Answer 1


If you can see your layer on a map using L.TileLayer, the problem is in the boundary polygon you pass in L.TileLayer.BoundaryCanvas. It is difficult to guess the exact problem without example sources, but you can try the following checks:

  • Add your layer using L.TileLayer and your boundary using L.Polygon (or using L.GeoJOSN). Check that your polygon corresponds to the location of your tiles.
  • Check that your boundary has no self-intersections or intersection of holes and outer ring. L.TileLayer.BoundaryCanvas can't work with such geometries.

Online example will be very usefull for more concrete answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.