I looked more into this.   Mapnik utilizes plugins for input which creates a 
problem because there's no direct interface to the GDAL plugin.  When you open 
a GDAL file in Mapnik it goes through each band and checks the GDALColorIntrep 
field for each RasterBand.  If it finds a band set to each of red/green/blue 
then you'll get an RGB band.  If even one is missing you'll get a grayscale 
image.   Note that if color info is not set the grayscale band used for 
rendering will always be the last band in the file.   It's during this time 
that the data is actually read in for these bands, so there's no hope for 
setting color bands in styles as at that point it's too late.   I also noted 
that the entire datafile is read in for the bands on open, the GDAL file handle 
is not kept around, simply read in and then ditched.   I don't think this is 
all that desirable because you are reading in the file at full resolution (what 
if you have a 10Kx10K raster?) and only downsized later during the
  rendering process.

I think this is an inherent problem in Mapnik's design because it greatly 
reduces its flexibility and has introduced some serious limitations.   I'm not 
sure the plugin method is the best approach especially with the existence of 
the GDAL/OGR library there isn't a need for other plugins.   The plugin design 
should be replaced simply with a fixed dependency on GDAL/OGR.  After all GDAL 
fairly easily supports addition of custom formats so adding a format to GDAL 
would extend to Mapnik.

I'd like to do this but it'd likely be a large job and difficult due to the 
general lack of documentation and comments.

matt



-----Original Message-----
From: Matt Bartolome [mailto:[EMAIL PROTECTED] 
Sent: Monday, June 16, 2008 8:11 PM
To: Matt Hanson
Cc: [email protected]
Subject: Re: [Mapnik-users] GDAL raster rendering

I'm going to try using tiffcp (libtiff-tools in ubuntu) to flatten the
geotiff and then manually set the extents.

Hopefully someone can chime in and shed some light on the
gdal/geotiff/rastersymbolizer stuff.

-Matt

On Mon, Jun 16, 2008 at 3:02 PM, Matt Hanson <[EMAIL PROTECTED]> wrote:
> Hi Matt, great question!  I say that because I've asked the same thing a
> couple times in the last week on both the user and dev lists (see my
> post from this morning).
>
> As near as I can tell mapnik gets the RGB bands when it reads in the
> image from the file itself, it's not set with the style.  I hope I'm
> wrong though because it really should be adjustable.
>
> In your case I'm not sure\hy it's not setting them to the default RGB
> bands that are in the file itself - I had thought that if there were
> bands set in the file that's what it used but if it's not doing that
> either...I'm not sure.
>
> I keep looking at the code trying to figure this out but nothing
> yet....I'll post back here if I figure it out.  Good luck!
>
>
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Matt
> Bartolome
> Sent: Monday, June 16, 2008 5:49 PM
> To: [email protected]
> Subject: [Mapnik-users] GDAL raster rendering
>
> Hi,
> I'm successfully rendering GeoTiffs using the GDAL datasource in gray
> scale but would like to render them in color. gdalinfo outputs:
>
> Band 1 Block=12001x1 Type=Byte, ColorInterp=Gray
>  Overviews: 3001x2001, 1501x1001, 751x501, 376x251, 188x126, 94x63
>  Metadata:
>    LAYER_TYPE=athematic
> Band 2 Block=12001x1 Type=Byte, ColorInterp=Undefined
>  Overviews: 3001x2001, 1501x1001, 751x501, 376x251, 188x126, 94x63
>  Metadata:
>    LAYER_TYPE=athematic
> Band 3 Block=12001x1 Type=Byte, ColorInterp=Undefined
>  Overviews: 3001x2001, 1501x1001, 751x501, 376x251, 188x126, 94x63
>  Metadata:
>    LAYER_TYPE=athematic
>
> All I've got in my style thus far is:
>
>  <Style name="raster">
>    <Rule>
>      <RasterSymbolizer>
>      </RasterSymbolizer>
>    </Rule>
>  </Style>
>
> When viewing the geotiff in arcmap it sets Red, Green, Blue as
> 120,123,100 automatically. Is that something read off the file that
> gdal isn't seeing or is that something I set myself?
>
> Thanks,
> Matt
> _______________________________________________
> 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
>
_______________________________________________
Mapnik-users mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/mapnik-users

Reply via email to