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="<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
_______________________________________________ Mapnik-users mailing list [email protected] https://lists.berlios.de/mailman/listinfo/mapnik-users

