[gdal-dev] vector representation in netcdf 4

Bekaert, David (334H) David.Bekaert at jpl.nasa.gov
Tue Jan 15 20:24:24 PST 2019


Hi GDAL developers, Even,

Thanks for sharing the updated sample product with srs info included.

I was able to mimic you polygon formatting in the attached TEST.nc file.
Unfortunately I was not able to get the srs info captured in my shape file when applying ogr2ogr.
I am using the same crs I used successful used for 2D rasters in nc4 (longitude latitude).
When I turn the debug mode on it states it looks for a geoTransform when generating the shapefile.
I therefore added a dummy geoTransform to my crs but that did not make a difference.
I am unsure why this would be needed for a polygon, but saw your sample has one in there too.

Any idea what I might be doing incorrectly or should modify in my crs?
Below I include the commandline outputs.

Thank you for your help,
David 


gdalinfo TEST.nc
Warning 1: dimension #1 (ogc_wkt_width) is not a Longitude/X dimension.
Warning 1: dimension #0 (record) is not a Latitude/Y dimension.
Warning 1: 1-pixel width/height files not supported, xdim: 191 ydim: 1
Driver: netCDF/Network Common Data Format
Files: TEST.nc
Size is 191, 1
Coordinate System is `'
Metadata:
  NC_GLOBAL#Conventions=CF-1.6
  NC_GLOBAL#ogr_geometry_field=ogc_wkt
  NC_GLOBAL#ogr_layer_name=poly
  NC_GLOBAL#ogr_layer_type=POLYGON
  ogc_wkt#grid_mapping=crs
  ogc_wkt#long_name=Geometry as ISO WKT
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,    1.0)
Upper Right (  191.0,    0.0)
Lower Right (  191.0,    1.0)
Center      (   95.5,    0.5)
Band 1 Block=191x1 Type=Byte, ColorInterp=Undefined
  NoData Value=0
  Metadata:
    grid_mapping=crs
    long_name=Geometry as ISO WKT
    NETCDF_VARNAME=ogc_wkt




ogr2ogr TEST.shp TEST.nc poly --config CPL_DEBUG on
GDAL_netCDF: driver detected file type=3, libnetcdf detected type=3
GDAL_netCDF: dim_count = 2
GDAL_netCDF: var_count = 2
GDAL_netCDF: 
=====
SetProjectionFromVar( 0)
GDAL_netCDF: got grid_mapping crs
GDAL_netCDF: bIsGdalFile=0 bIsGdalCfFile=0 bBottomUp=1
GDAL_netCDF: got spheroid from CF: (6378137.000000 , 298.257224)
GDAL_netCDF: bGotGeogCS=1 bGotCfSRS=1 bGotCfGT=0 bGotGdalSRS=0 bGotGdalGT=0
GDAL_netCDF: did not get geotransform from CF nor GDAL!
GDAL: GDALOpen(TEST.nc, this=0x7fa035c3b060) succeeds as netCDF.
GDAL: Using ESRI Shapefile driver
GDAL: QuietDelete(TEST.shp) invoking Delete()
GDAL: GDALDriver::Create(ESRI Shapefile,TEST.shp,0,0,0,Unknown,0x0)
Shape: DBF Codepage = LDID/87 for TEST.shp
Shape: Treating as encoding 'ISO-8859-1'.
OGR: Created dummy FID field for shapefile since schema is empty.
GDALVectorTranslate: 1 features written in layer 'TEST'
GDAL: GDALClose(TEST.nc, this=0x7fa035c3b060)
GDAL: GDALClose(TEST.shp, this=0x7fa035c88ed0)



On 1/11/19, 2:11 PM, "Even Rouault" <even.rouault at spatialys.com> wrote:

    David,
    
    No need to test with QGIS, ogrinfo also shows that the SRS isn't recognized.
    
    This sample files was quickly hand generated with ncdump/ncgen without taking 
    much care to the georeferencing. It lacks referencing the transverse_mercator 
    variable in the vector fields.
    
    Like:
    
    	char ogc_wkt(record, ogc_wkt_max_width) ;
    		ogc_wkt:long_name = "Geometry as ISO WKT" ;
    		ogc_wkt:grid_mapping = "transverse_mercator" ;
    	double AREA(record) ;
    		AREA:long_name = "Field AREA" ;
    		AREA:ogr_field_name = "AREA" ;
    		AREA:ogr_field_type = "Real" ;
    		AREA:ogr_field_width = 12 ;
    		AREA:ogr_field_precision = 3 ;
    		AREA:grid_mapping = "transverse_mercator" ;
    	double EAS_ID(record) ;
    		EAS_ID:long_name = "Field EAS_ID" ;
    		EAS_ID:ogr_field_name = "EAS_ID" ;
    		EAS_ID:ogr_field_type = "Integer64" ;
    		EAS_ID:ogr_field_width = 11 ;
    		EAS_ID:grid_mapping = "transverse_mercator" ;
    	char PRFEDEA(record, PRFEDEA_max_width) ;
    		PRFEDEA:long_name = "Field PRFEDEA" ;
    		PRFEDEA:ogr_field_name = "PRFEDEA" ;
    		PRFEDEA:ogr_field_type = "String" ;
    		PRFEDEA:ogr_field_width = 16 ;
    		PRFEDEA:grid_mapping = "transverse_mercator" ;
    
    Actually I've just tried adding this and it works now. Modified file attached
    
    Even
    
    > Dear GDAL developers,
    > 
    > I am looking into adding a wkt compatible polygon into a netcdf (version 4)
    > file which also has raster information in it.
     Attached is a sample file
    > generated by Even “mixed.nc” with a wkt polygon enclosed formatted as a
    > string of numpy array. The sample allows to extract a poly using ogr2ogr as
    > “ogr2ogr mixed.shp mixed.nc poly” 
    > Although QGIS does not seem to catch projection information.
    > Is there a standard way of storing vector information in netcdf conform CF
    > or would the attached sample be specifically for GDAL only?
     
    > Thank you,
    > David
    > 
    
    
    -- 
    Spatialys - Geospatial professional services
    http://www.spatialys.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: TEST.shp
Type: application/octet-stream
Size: 236 bytes
Desc: TEST.shp
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190116/34c275fc/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TEST.nc
Type: application/octet-stream
Size: 13047 bytes
Desc: TEST.nc
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20190116/34c275fc/attachment-0003.obj>


More information about the gdal-dev mailing list