[gdal-dev] gdal_rasterize with a NetCDF file?

Scott Lewis scott.lewis at nsidc.org
Mon Sep 21 14:37:08 EDT 2009


Evan,

Thanks, that seems to be getting me in the right direction: I'm no
longer getting the segfault error, or "ERROR 5" at all.

However, now it's giving me a different error.  The first line has the:
0...10...20...30...40...50...60...70...80...90...100 - done.
message, like I would expect from when I do this with GeoTIFF files.
But following that I am getting a whole bunch of this error, repeated
many times:

ERROR 6: WriteBlock() not supported for this dataset.


Doing a search online, I'm getting the impression that this might mean
that gdal_rasterize doesn't support writing to a NetCDF file?  Is this
correct, or does the problem lie elsewhere with my calling of the utility.

Here's the command line I'm using now:

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


Thanks again for the help!

Scott


Even Rouault wrote:
> Selon Scott Lewis <scott.lewis at nsidc.org>:
> 
> Scott,
> 
> Anytime you want to access to a subdataset with a gdal utility, you must use the
> value of the relevant SUBDATASET_xxx_NAME metadata item, in that instance
> 'NETCDF:"Albedo.nc":Albedo_with_1400_Local_Time_of_Measurement'
> 
> The segmentation fault however wasn't expected, so I commited fixes per ticket
> http://trac.osgeo.org/gdal/ticket/3146 to error out more nicely.
> 
> Best regards
> 
>> 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
>> _______________________________________________
>> 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