I want to create a multi-colored raster layer to overlay on my map in OpenLayers

I have the following information in my DataBase:

D_Cell_ID          Long            Lat         ColorCode
055113             121.4698        40.8417     FF6600
057113             121.4698        40.8325     FF6600
063125             121.0344        40.4658     FFCC00
063127             121.0344        40.4567     FFCC00

I would like to have the output something similar like this:Example

raster overlay

Hence I need to write some code to create a raster image based on long,latt,color information.

Do anyone know how to do this or of any library tool which can import into Java environment to do this?

Method and direction is needed.


One way to do it is to see if you can get d3 to work with openlayers. D3 will plot on top of openlayers on the client side of the browser.

There are some demo's listed here, but they seem to be waiting for a websocket to respond before the tiles get in;



It depends on how attached you are to openlayers, leaflet might offer you a good alternative, it allows for plotting geojson ontop of its maps straight. It also has great d3 support.

  • What is the performance different between I use OpenLayers.Format.GeoJSON to add the vector layer compare to using d3? – jhyap Jan 25 '14 at 14:48
  • I would not know openlayers too well. D3 basically places SVG elements ontop of your map. Openlayers might have a similar feature, the benefit of d3 is that you would have more interactivity. D3 is a steep learning curve though. – Vincent Warmerdam Jan 25 '14 at 15:47

If your data is on a regular (ie equally-spaced) lat-long grid, then you can use Geotools or the GDAL Java bindings to create a georeferenced image file - basically an image file with metadata saying where the pixels are.

Having done that, add the image to your OpenLayers map as an Image layer: http://dev.openlayers.org/apidocs/files/OpenLayers/Layer/Image-js.html with the correct extent.

Note the layer in the example site you gave is showing tiles from a tile server - these look like they are probably pre-rendered from polygonal vector data.


I think, you'll find in the Geotools library, what you are looking for :


There are an objet which aim is to write GeoTiff file :


After you can serve the generated Geotiff file throught Geoserver.

Your Answer

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

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