[gdal-dev] gdal_rasterize with a NetCDF file?

Scott Lewis scott.lewis at nsidc.org
Mon Sep 21 12:14:18 EDT 2009


Hi,

I'm still fairly new at using GDAL, but I am having trouble burning a
vector image onto a NetCDF file.  I've had success with using
gdal_rasterize to burn a vector onto a GeoTIFF file, but when I try to
burn the same vector onto a NetCDF file, I get an error.

Based on the error, I'm suspecting it's because it doesn't know how to
find the right "band" in the NetCDF File (I want the
"Albedo_with_1400_Local_Time_of_Measurement" subdataset), but although
I've looked at the documentation, I'm not sure how to specify this to
gdal_rasterize.

Any help would be much appreciated!  Below is the info.



Here is the command I am trying to run:

/usr/local/FWTools-2.0.6/bin_safe/gdal_rasterize -i -burn 0 -l
"OGRGeoJSON" dummy.json Albedo.nc


And the error I get:

ERROR 5: GDALDataset::GetRasterBand(1) - Illegal band #

/usr/local/FWTools-2.0.6/bin_safe/gdal_rasterize: line 9: 26950
Segmentation fault      $FWTOOLS_HOME/bin/`basename $TARGET` "$@"



Here is the gdalinfo for Albedo.nc:

Driver: netCDF/Network Common Data Format
Files: Albedo.nc
Size is 512, 512
Coordinate System is `'
Metadata:
  NC_GLOBAL#Conventions=CF-1.4
  NC_GLOBAL#institution=National Snow & Ice Data Center, Boulder, CO
  NC_GLOBAL#title=AVHRR Polar Pathfinder Twice-Daily 5 km EASE-Grid
Composites Albedo
  NC_GLOBAL#source=See the title and references for this information
  NC_GLOBAL#comment=Not set at this time
  NC_GLOBAL#references=Documentation available at:
http://nsidc.org/data/docs/daac/nsidc0066_avhrr_5km.gd.html
  NC_GLOBAL#history=Mon, 21 Sep 2009 09:31:24: File created.
Subdatasets:

SUBDATASET_1_NAME=NETCDF:"Albedo.nc":Albedo_with_1400_Local_Time_of_Measurement
  SUBDATASET_1_DESC=[1x244x242]
Albedo_with_1400_Local_Time_of_Measurement (8-bit integer)
  SUBDATASET_2_NAME=NETCDF:"Albedo.nc":latitude
  SUBDATASET_2_DESC=[244x242] latitude (64-bit floating-point)
  SUBDATASET_3_NAME=NETCDF:"Albedo.nc":longitude
  SUBDATASET_3_DESC=[244x242] longitude (64-bit floating-point)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)


And for completeness, the dummy.json file (it's basically a triangle):

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "properties": { "BASIN_ID": 1.000000, "AREA_SQKM": 1739.016470 },
        "geometry": {
            "type": "Polygon",
            "coordinates": [ [
                [ -2000000, -2500000 ],
                [ -2500000, -1400000 ],
                [ -1500000, -1400000 ],
                [ -2000000, -2500000 ]
            ] ]
        }
    }]
}



Thanks!

Scott Lewis
National Snow & Ice Data Center


More information about the gdal-dev mailing list