[gdal-dev] bring through shapefile attribute in gdal_rasterize

Eli Adam eadam at co.lincoln.or.us
Mon Apr 9 10:49:54 EDT 2012


Derek,

> This may be a simple question for most of you but I thought I would
> ask it anyhow as I am at an impasse.  I have a Counties shape file.  I
> am attempting to convert it to raster utilizing gdal_rasterize, and
> this does work.  However, I am attempting to carry into the output
> file the county name preferably e.g. Orange County, or at least a
> county identify of some kind.  I have utilized a command similar to
> the following:
>
> gdal_rasterize -a COUNTY  -l -sql "select COUNTY, * from Counties"
> Counties Counties.shp CountiesRaster.tif

I think that -l should specify the layer name from the source dataset
not the field.  Typically in a shapefile there is only one layer and
it is the same as the shapefile name.  Try dropping the -l stuff all
together.

gdal_rasterize -a COUNTY Counties.shp CountiesRaster.tif

or if you use it, use it like this:

gdal_rasterize -a COUNTY -l Counties Counties.shp CountiesRaster.tif

>
> However, when I open the resulting raster file in ArcGIS and click on
> one of the pixel to identify it I don’t see the county name. Is the
> county name there and I am just not seeing it in ArcGIS indentify.  I
> realize there are probably more GDAL intensive ways to check for the
> data, but I am still learning. I was hoping to someone could explain
> to me what I am doing incorrectly.

You can get information from a raster in GDAL with gdallocationinfo.

HTH, Eli

>
> Thanks,
> Derek
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list