[OpenLayers-Users] Help needed with using OpenLayers.Layer.Image

James Hiebert hiebert at uvic.ca
Wed Feb 24 12:52:03 EST 2010


OpenLayers Users,

I ended up figuring out the answer to my problem below.  I had most of the
geo-referencing correct, but the Image layer doesn't work with geotiffs (or
tiffs for that matter), which I probably should have guessed.

I converted the tiff to a gif (and probably could use a jpg, png or any
other web image format), set the layer's maxResolution to be geotiff's
resolution (in meters / pixel) and everything worked like a charm.

Maybe it was already obvious to everyone else, but could someone add a
little info to the API docs for OpenLayers.Layer.Image as to what image
formats should be expected to work?

~James Hiebert

On Tue, Feb 23, 2010 at 03:51:29PM -0800, James Hiebert wrote:
> Hi All,
> 
> I'm working on a project where I'd like to take an image raster and overlay
> that on top of a OpenLayers base layer (from OpenStreetMap).  I have my
> raster in a geotiff which I have created from the data (climate temperature
> data, not that it makes any difference).
> 
> I'm having problems understanding what options and attributes I need to
> actually set when creating the instance of OpenLayers.Layer.Image (the
> documentation does not seem to be very complete or verbose).
> 
> I've gdalwarp'ed my geotiff to match the projection of the base layer
> (EPSG:900913).  I'm fairly certain that my geotiff is fine... it loads into
> QGIS fine and is displayed by standard image viewers like xview and eog
> without problems.
> 
> In my openlayers example I hard coded the bounds and the rater size based on
> the output of tiffinfo and passed those to the constructor.  Are the bounds
> supposed to be map coordinates (EPSG:900913) or in LatLon?
> 
> When I load the page, the base layer (OpenStreetMap) displays fine, but my
> overlay ("Autumn tmax...") is greyed out in the layer switcher.  The layer's
> name is "climate" and if I do a: climate.calculateInRange() it returns
> false.  Seems that the auto resolution calculation is not working since
> climate.resolutions and osm.resolutions (the base layer) are very, very
> different.
> 
> >>> climate.resolutions
> [0.32142857142857145, 0.16071428571428573, 0.08035714285714286,
> 0.04017857142857143, 0.020089285714285716, 0.010044642857142858,
> 0.005022321428571429, 0.0025111607142857145, 0.0012555803571428572,
> 0.0006277901785714286, 0.0003138950892857143, 0.00015694754464285715,
> 0.00007847377232142858, 0.00003923688616071429, 0.000019618443080357144,
> 0.000009809221540178572]
> >>> osm.resolutions
> [156543.0339, 78271.51695, 39135.758475, 19567.8792375, 9783.93961875,
> 4891.969809375, 2445.9849046875, 1222.99245234375, 611.496226171875,
> 305.7481130859375, 152.87405654296876, 76.43702827148438, 38.21851413574219,
> 19.109257067871095, 9.554628533935547, 4.777314266967774, 2.388657133483887,
> 1.1943285667419434, 0.5971642833709717]
> 
> This is probably because I didn't supply an option that I'm supposed to, but
> I can't figure it out.  Could someone more knowledgable than I about the
> Layer.Image take a look at it for me?
> 
> My trimmed down example can be found here:
> http://basalt.pcic.uvic.ca/index-mini.html
> 
> Any help or suggestions is much appreciated.
> 
> ~James Hiebert
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users



More information about the Users mailing list