1

I am using and playing around with Cesium at the moment, and I am enjoying the functionality so far. I am trying to provide my own imagery to Cesium with the TMS imagery provider:

imageryProvider: new Cesium.createTileMapServiceImageryProvider({ 
  url: <my path>, 
  credit: "Some credit goes here..."
})

To create the tiles that I will need from a large tiff image, I am using the gdal command line utilities. Particularly, I am using gdalinfo, gdal_translate, gdalwarp and gdal2tiles.py. The image that I am starting off with is a tiff image with the following properties:

Driver: GTiff/GeoTIFF
Files: pleiades_pan05m_2015-06-19.tif
Size is 52251, 56122
Coordinate System is:
PROJCS["WGS 84 / UTM zone 35S",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433],
        AUTHORITY["EPSG","4326"]],
    PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",27],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",10000000],
    UNIT["meters",1],
    AUTHORITY["EPSG","32735"]]
Origin = (606275.000000000000000,7197875.000000000000000)
Pixel Size = (0.500000000000000,-0.500000000000000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_MAXSAMPLEVALUE=4095
  TIFFTAG_MINSAMPLEVALUE=1
  TIFFTAG_RESOLUTIONUNIT=2 (pixels/inch)
  TIFFTAG_SOFTWARE=ERDAS IMAGINE
  TIFFTAG_XRESOLUTION=1
  TIFFTAG_YRESOLUTION=1
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (  606275.000, 7197875.000) ( 28d 3'21.55"E, 25d19'55.05"S)
Lower Left  (  606275.000, 7169814.000) ( 28d 3'29.52"E, 25d35' 7.16"S)
Upper Right (  632400.500, 7197875.000) ( 28d18'55.91"E, 25d19'47.53"S)
Lower Right (  632400.500, 7169814.000) ( 28d19' 5.83"E, 25d34'59.55"S)
Center      (  619337.750, 7183844.500) ( 28d11'13.20"E, 25d27'27.53"S)
Band 1 Block=512x512 Type=UInt16, ColorInterp=Gray

Using gdal_translate, I first georeference the image by defining the ground control points, and choose an output format of VRT:

gdal_translate -of VRT -gcp 606275 7197875 28.055987 -25.331974 -gcp 606275 7169814 28.058200 -25.585326 -gcp 632400.5 7197875 28.31553 -25.329876 -gcp 632400.5 7169814 28.318286 -25.583209 pleiades_pan05m_2015-06-19.tif output1.vrt

After this step, I warp the image. The original image wasn't created for a round globe, and a new projection (which Cesium requires) is necessary. My command I executed was:

gdalwarp -of VRT -t_srs EPSG:3857 output1.vrt output2.vrt

This warps the image to fit the globe in Cesium and creates a new output file which provides metadata about the warping procedure.

As a final step, I want to create the tiles. For this I used the python binding script gdal2tiles.py as follows:

gdal2tiles.py -v output2.vrt

The output for this command (using the verbose option) gave me the following output:

('Options:', <Values at 0x7f51a6c6eea8: {'profile': 'mercator', 'kml': False, 's_srs': None, 'copyright': '', 'resume': False, 'url': '', 'googlekey': 'INSERT_YOUR_KEY_HERE', 'bingkey': 'INSERT_YOUR_KEY_HERE', 'webviewer': 'all', 'zoom': None, 'resampling': 'average', 'tmscompatible': None, 'title': 'denel2.vrt', 'srcnodata': None, 'verbose': True}>)
('Input:', 'output2.vrt')
('Output:', 'output2')
Cache: 40 MB

('Input file:', '( 55470P x 54022L - 1 bands)')
NODATA: []
('Preprocessed file:', '( 55470P x 54022L - 1 bands)')
('Bounds (output srs):', 22.6588553403505, -90.3653010581841, 23.18345039115748, -89.8544001417483)
('Bounds (latlong):', (-0.000811765310920372, 0.00020354796072890105), (-0.0008071758099030093, 0.0002082604782500346))
('MinZoomLevel:', 26)
Traceback (most recent call last):
  File "/usr/bin/gdal2tiles.py", line 2278, in <module>
    gdal2tiles.process()
  File "/usr/bin/gdal2tiles.py", line 482, in process
    self.open_input()
  File "/usr/bin/gdal2tiles.py", line 991, in open_input
    print("MaxZoomLevel:", self.tmaxz, "(", self.mercator.Resolution( self.tmaxz ),")")
  File "/usr/bin/gdal2tiles.py", line 286, in Resolution
    return self.initialResolution / (2**zoom)
TypeError: unsupported operand type(s) for ** or pow(): 'int' and 'NoneType'

When I take away the verbose option, I get a similar error but at a different place:

Traceback (most recent call last):
  File "/usr/bin/gdal2tiles.py", line 2278, in <module>
    gdal2tiles.process()
  File "/usr/bin/gdal2tiles.py", line 485, in process
    self.generate_metadata()
  File "/usr/bin/gdal2tiles.py", line 1135, in generate_metadata
    f.write( self.generate_tilemapresource())
  File "/usr/bin/gdal2tiles.py", line 1531, in generate_tilemapresource
    for z in range(self.tminz, self.tmaxz+1):
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

I am kind of stuck here at the moment, will anyone be able to help out here? Why (when I don't pass the verbose option), I get a NoneType error and why self.tmaxz is of type 'NoneType'? Am I missing something in my steps above?

  • you may want to provide some sample data to make it reproducible. – dof1985 Jun 25 '16 at 17:13
  • The original seems to be already georeferenced for EPSG:32735 so you do not need to write any ground control points. Gdal2tiles should work directly by using pleiades_pan05m_2015-06-19.tif as the source image. – user30184 Jun 26 '16 at 20:03
  • @user30184 I need the file to be projected to EPSG:3857 for Cesium. Should I then leave out the gdal_translate step? – effort Jun 27 '16 at 9:21
  • Gdal2tiles can do reprojection and the default profile is EPSG:3857 -p PROFILE, –profile=PROFILE: Tile cutting profile (mercator,geodetic,raster) - default 'mercator' (Google Maps compatible). – user30184 Jun 27 '16 at 9:24
  • Isn't the default profile EPSG:4326? – effort Jun 27 '16 at 9:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.