Hi Amy,

The issue is basically that the "raster" input plugin cannot handle 64 bit images. We've now fixed the code in trunk to throw this error:

"Raster Plugin: image reader exception caught: Sorry, can not handle images with 64-bit samples"

In your case the best the solution is to use the GDAL plugin instead:

Change your XML to something like:

                <Datasource>
                        <Parameter name="type">gdal</Parameter>
                        <Parameter name="file">new.tif</Parameter>
                        <Parameter name="band">1</Parameter>
                </Datasource>

Using that datasource, with band 1, I can get the attached PNG image. Does that look right?

Dane

On Apr 11, 2011, at 7:27 AM, Maples, Amy C. wrote:

Dane,
I’ve attached a copy of the tiff I’m trying to display.
-Amy
 
From: Maples, Amy C. 
Sent: Monday, April 11, 2011 10:22 AM
To: 'Dane Springmeyer'
Cc: [email protected]
Subject: RE: [Mapnik-users] Displaying raster data with mapnik2
 
Dane,
I’ve attached a copy of the tiff I’m trying to display.
-Amy
 
From: Dane Springmeyer [mailto:[email protected]] 
Sent: Saturday, April 09, 2011 8:45 PM
To: Maples, Amy C.
Cc: [email protected]
Subject: Re: [Mapnik-users] Displaying raster data with mapnik2
 
Hi Amy. Would it be possible to post your raster data as well? (or at least a small clip of it).
 
Dane

--- \o/ ---
Sent from my phone


On Apr 7, 2011, at 11:33 AM, "Maples, Amy C." <[email protected]> wrote:

Mapnik-users,
 
I’m trying to display a raster geotiff image using mapnik2.  Based on all the documentation and example code, I’ve written an xml file to create a layer with the appropriate style.  In order to test this, I have a simple python script.  However, when I call “mapnik2.load_map(m, mapfile)” I get the message “Raster Plugin: exception caught”, which is a little vague.  The resulting plot is empty whether I’m using the “us” or “nozoom” levels in the python script (different types of bbox coordinates).  I’ve used this python script before for plotting vector data with mapnik, so I believe the problem is with the xml file.  Any help on what I might be overlooking would be greatly appreciated.
 
Thanks,
Amy Maples
Noblis, Inc.
 
 
Python script:
#!/usr/bin/env python
# first arguement is xml file name
# second argument is zoom level(all lower case)--can be nozoom, us, state, city, locale, street
import sys
import mapnik2
if not sys.argv[1:]:
        sys.argv += ['climateTest.xml']
        #sys.argv += ["argument1", "argument2", "argument3"]
if (len(sys.argv)<=2):
        zoom='nozoom'
else:
        zoom=sys.argv[2]
mapfile = sys.argv[1]
map_output = mapfile[:-4]+'_'+zoom+'.png'
m = mapnik2.Map(1000,500)
mapnik2.load_map(m, mapfile)
if (zoom=='nozoom'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-14911468.431, 2242177.475), mapnik2.Coord(-6158842.809, 8775827.587))
elif (zoom=='us'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-133.952,219.444), mapnik2.Coord(-55.577,61.647))
elif (zoom=='state'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-84,37), mapnik2.Coord(-76,40))
elif (zoom=='city'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-77,39), mapnik2.Coord(-77,39))
elif (zoom=='locale'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-77.242,38.8399), mapnik2.Coord(-77.195,38.873))
elif (zoom=='street'):
        bbox = mapnik2.Box2d(mapnik2.Coord(-77.219253,38.858257), mapnik2.Coord(-77.211013,38.866544))
else:
        bbox = mapnik2.Box2d(mapnik2.Coord(-180.0, -90.0), mapnik2.Coord(180.0, 90.0))
m.zoom_to_box(bbox)
mapnik2.render_to_file(m, map_output)
 
 
climateTest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Map>
<Map srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs">
        <Style name="tk">
                <Rule>
                        <RasterSymbolizer>
                                <RasterColorizer>
                                        <ColorBand value="250" color="rgb(238,130,238)" label="&lt;0"></ColorBand>
                                        <ColorBand value="260" color="rgb(75,0,130)" midpoints="199"></ColorBand>
                                        <ColorBand value="270" color="rgb(0,0,255)" midpoints="199"></ColorBand>
                                        <ColorBand value="280" color="rgb(0,128,0)" midpoints="199"></ColorBand>
                                        <ColorBand value="290" color="rgb(255,205,0)" midpoints="199"></ColorBand>
                                        <ColorBand value="300" color="rgb(255,127,0)" midpoints="199"></ColorBand>
                                        <ColorBand value="310" color="rgb(196,2,51)"></ColorBand>
                                </RasterColorizer>
                        </RasterSymbolizer>
                </Rule>
        </Style>
        <Layer name="RegCM_tk_NCAR_historical_1" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs">
                <StyleName>tk</StyleName>
                <Datasource>
                        <Parameter name="type">raster</Parameter>
                        <Parameter name="file">/home/amaples/new.tif</Parameter>
                        <Parameter name="lox">-14911468.431</Parameter>
                        <Parameter name="loy">2242177.475</Parameter>
                        <Parameter name="hix">-6158842.809</Parameter>
                        <Parameter name="hiy">8775827.587</Parameter>
                </Datasource>
        </Layer>
</Map>
 
 
GDALINFO new.tif:
Driver: GTiff/GeoTIFF
Files: new.tif
Size is 71, 53
Coordinate System is:
PROJCS["unnamed",
    GEOGCS["unnamed ellipse",
        DATUM["unknown",
            SPHEROID["unnamed",6378137,0]],
        PRIMEM["Greenwich",0],
        UNIT["degree",0.0174532925199433]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,
        AUTHORITY["EPSG","9001"]]]
Origin = (-14911468.430740585550666,8775827.586873944848776)
Pixel Size = (123276.417201214062516,-123276.417201214062516)
Metadata:
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-14911468.431, 8775827.587) (133d57'7.20"W, 61d38'47.76"N)
Lower Left  (-14911468.431, 2242177.475) (133d57'7.20"W, 19d44'21.62"N)
Upper Right (-6158842.809, 8775827.587) ( 55d19'32.97"W, 61d38'47.76"N)
Lower Right (-6158842.809, 2242177.475) ( 55d19'32.97"W, 19d44'21.62"N)
Center      (-10535155.620, 5509002.531) ( 94d38'20.09"W, 44d16'50.94"N)
Band 1 Block=71x14 Type=Float64, ColorInterp=Gray
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users
<new.tif>

_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to