<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Thanks Andrew and Richard,</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Very good examples.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
I have struggled with that so many times when developing GDAL drivers or when dealing with data in formats like HDF4, HDF5, NetCDF.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Some formats have a pretty good easy way of telling which way to go about upperleft or center pixel coordinate. But that is not the case with "flexible" formats like the ones above. In some cases developer have to identify the data product in a hardcode way
and apply what the documentation says about the data, not only in regards to pixel coordinate but other issues.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
What is interesting in that case is that one can say that according to the documentation the driver is correct. The -180,80 coordinate is in the center of the pixel. But when putting that date to real use, that seems to be incorrect.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
And that could be dangerous or at least inconvenient. In my case I have a Python code that does zonal statistic and when a geometry is converted to a little raster binary mask, it does not match the same area in the ProbaV data and the results is a crash in
Fiji because ReadRaster goes overboard or lost of NDVI data in other regions. The half pixel shift grows as you go east. </div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
In other case, a GIS user might find impossible to run a raster tool, because it will complain that all the raster sources that they are trying to combine does not match the same area. There are still some tool like that in the marked, unfortunately.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
If I have some time, I will try to run the NetCDF driver in step-by-step debugging mode to see exactly how the crs:GeoTransform is (mis)handled.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
The goal is to see if the data is wrong or if the driver is wrong (or if I am wrong) and to decided how to go from here. We might need to add some hardcoded decision into the NetCDF driver, which I would prefer not to do.</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Best regards,</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
Ivan</div>
<div style="color: rgb(0, 0, 0); font-family: Calibri,Helvetica,sans-serif; font-size: 12pt;">
<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Andrew C Aitchison <andrew@aitchison.me.uk><br>
<b>Sent:</b> Friday, November 1, 2019 7:24 AM<br>
<b>To:</b> Richard Duivenvoorde <rdmailings@duif.net><br>
<b>Cc:</b> Ivan Lucena <ivan.lucena@outlook.com>; gdal-dev@lists.osgeo.org <gdal-dev@lists.osgeo.org><br>
<b>Subject:</b> Re: [gdal-dev] NetCDF and ESA Probav issue with corner coordimates</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText"><br>
Does<br>
<a href="https://gis.stackexchange.com/questions/122670/is-there-a-standard-for-the-coordinates-of-pixels-in-georeferenced-rasters#122687">
https://gis.stackexchange.com/questions/122670/is-there-a-standard-for-the-coordinates-of-pixels-in-georeferenced-rasters#122687</a><br>
help you to understand the issue ?<br>
<br>
On Fri, 1 Nov 2019, Richard Duivenvoorde wrote:<br>
<br>
> Hi Ivan,<br>
><br>
> I think I reported an issue like this some time ago in the QGIS issue<br>
> tracker:<br>
><br>
> <a href="https://issues.qgis.org/issues/20730">https://issues.qgis.org/issues/20730</a><br>
><br>
> I think(!), but I hope some netcdf guru jumps in, that the crux is how<br>
> you define/interpret your data: is the value valid in the center of the<br>
> grid (like a raster) or is it on the vertices (more like a mesh).<br>
> It is all about interpretation of a datamodel: is it a grid or a raster.<br>
><br>
> If I understand correctly in a mesh (and netcdf) is much more possible<br>
> then in a raster: triangular meshes, non-regular etc etc:<br>
><br>
> <a href="https://docs.qgis.org/3.4/en/docs/user_manual/working_with_mesh/mesh_properties.html">
https://docs.qgis.org/3.4/en/docs/user_manual/working_with_mesh/mesh_properties.html</a><br>
><br>
> I'm not sure who should be responsible for 'correcting/transforming'<br>
> this: a netcdf which is written as if the values are on (for example)<br>
> the upper-left corner vertices, while you actually mean the value is in<br>
> the center of a (grid)cell... For a simple rectangular mesh, this seems<br>
> feasible on the client side (see panoply example in first link), but for<br>
> non-regular meshes/netcdf's this seems impossible client side (well<br>
> actually that is not a raster/grid anymore)..<br>
><br>
> In your case I would think that the data is actually mend to be a grid...<br>
><br>
> Not sure if this is helpfull, as said I hope some netcdf guru jumps in.<br>
> Maybe I'm oversimplifying here...<br>
><br>
> Regards,<br>
><br>
> Richard Duivenvoorde<br>
><br>
> On 31/10/2019 22.06, Ivan Lucena wrote:<br>
>><br>
>> Hi Folks,<br>
>><br>
>> I Downloaded NetCDF files<br>
>> from?http://land.copernicus.eu/global/products/ndvi and I am having<br>
>> problems with the GeoTransform that the driver is getting.<br>
>><br>
>> The image extents, as you can see in following gdalinfo report, goes<br>
>> beyond the -180 and +180 longitude degrees (half resolution, half pixel)<br>
>> but that's OK according to page 27 in the PDF documentation:<br>
>> PROBAV-Products_User_Manual_v1.3.pdf<br>
>> <<a href="https://earth.esa.int/documents/700255/1929094/PROBAV-Products_User_Manual_v1.3.pdf/fd5e30f4-5305-4d41-86aa-fab7b9568251">https://earth.esa.int/documents/700255/1929094/PROBAV-Products_User_Manual_v1.3.pdf/fd5e30f4-5305-4d41-86aa-fab7b9568251</a>>?<br>
>><br>
>> But if I open that image on QGIS and overlay a vector (GADM from<br>
>> gadm.org) or any other global layer it is clear that -180x80 should be<br>
>> in the upper left corner of the image, not In the center. There is a<br>
>> half pixel missing on the left and bottom of the image. This in in Fiji:<br>
>><br>
>><br>
>><br>
>> The gdalinfo report shows that the crs:GeoTransform is?-180.0000000000<br>
>> 0.0029761905 0.0 80.0000000000 0.0 -0.0029761905 but it seems like the<br>
>> driver decided to take that to as center of the pixel based. Looking at<br>
>> the NetCDF source I can see that there this possibility exists.<br>
>><br>
>> Of course, I am not waiting for a solution. I just used gdal_translate<br>
>> "- a_ullr" and fix that into the target format. It takes centuries to<br>
>> converted that image to geotiff. But I am concerned that others might<br>
>> get in trouble because of that.<br>
>><br>
>> I tried to contact the data provider but did not received an answer yet.<br>
>><br>
>> Does anybody has experience with that dataset and/or NetCDF that can<br>
>> help figure out what is going on. It is a bug in the driver or an issue<br>
>> with the data.<br>
>><br>
>> Thanks,<br>
>><br>
>> -<br>
>> Ivan<br>
>><br>
>> Here is the gdalinfo report:<br>
>><br>
>> Don't worry about the warnings in regards to the pixel values. It is fine.<br>
>><br>
>> $ gdalinfo netcdf:c_gls_NDVI300_201910110000_GLOBE_PROBAV_V1.0.1.nc<br>
>> --debug on<br>
>> GDAL_netCDF: driver detected file type=5, libnetcdf detected type=3<br>
>> Warning 1: NetCDF driver detected file type=5, but libnetcdf detected<br>
>> type=3<br>
>> GDAL_netCDF: setting file type to 3, was 5<br>
>> GDAL_netCDF: dim_count = 2<br>
>> GDAL_netCDF: var_count = 4<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute _FillValue<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute missing_value<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute flag_values<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute valid_range<br>
>> GDAL_netCDF:<br>
>> =====<br>
>> SetProjectionFromVar( 3)<br>
>> *GDAL_netCDF: got grid_mapping crs*<br>
>> GDAL_netCDF: bIsGdalFile=1 bIsGdalCfFile=0 bBottomUp=0<br>
>> GDAL_netCDF: got spheroid from CF: (6378137.000000 , 298.257224)<br>
>> GDAL_netCDF: set bBottomUp = 0 from Y axis<br>
>> GDAL_netCDF: setting WKT from CF<br>
>> GDAL_netCDF: SetProjection, WKT =<br>
>> GEOGCS["unknown",DATUM["unknown",SPHEROID["Spheroid",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]]]<br>
>> <br>
>> GDAL_netCDF: xdim: 120960 nSpacingBegin: 3 nSpacingMiddle: 3<br>
>> nSpacingLast: 3<br>
>> GDAL_netCDF: ydim: 47040 nSpacingBegin: -3 nSpacingMiddle: -3<br>
>> nSpacingLast: -3<br>
>> GDAL_netCDF: setting WKT from GDAL<br>
>> GDAL_netCDF: SetProjection, WKT = GEOGCS["WGS<br>
>> 84",DATUM["WGS_1984",SPHEROID["WGS<br>
>> 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]<br>
>> <br>
>> *GDAL_netCDF:<br>
>> SetGeoTransform(-180.001488,0.002976,0.000000,80.001488,0.000000,-0.002976)<br>
>> *<br>
>> GDAL_netCDF: bGotGeogCS=1 bGotCfSRS=1 bGotCfGT=1 bGotGdalSRS=1 bGotGdalGT=0<br>
>> Warning 1: Unsupported netCDF datatype (7), treat as Float32.<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute _FillValue<br>
>> GDAL_netCDF: netcdf type=5 gdal type=6 signedByte=1<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute _FillValue<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute missing_value<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute flag_values<br>
>> GDAL_netCDF: NCDFGetAttr unsupported type 7 for attribute valid_range<br>
>> GDAL_netCDF: got add_offset=-0.07999999821186066, status=0<br>
>> GDAL_netCDF: got scale_factor=0.004000000189989805, status=0<br>
>> GDAL: GDALOpen(netcdf:c_gls_NDVI300_201910110000_GLOBE_PROBAV_V1.0.1.nc,<br>
>> this=00000219E2D291F0) succeeds as netCDF.<br>
>> Driver: netCDF/Network Common Data Format<br>
>> GDAL: GDALDefaultOverviews::OverviewScan()<br>
>> Files: none associated<br>
>> Size is 120960, 47040<br>
>> Coordinate System is:<br>
>> GEOGCS["WGS 84",<br>
>> ? ? DATUM["WGS_1984",<br>
>> ? ? ? ? SPHEROID["WGS 84",6378137,298.257223563,<br>
>> ? ? ? ? ? ? AUTHORITY["EPSG","7030"]],<br>
>> ? ? ? ? TOWGS84[0,0,0,0,0,0,0],<br>
>> ? ? ? ? AUTHORITY["EPSG","6326"]],<br>
>> ? ? PRIMEM["Greenwich",0,<br>
>> ? ? ? ? AUTHORITY["EPSG","8901"]],<br>
>> ? ? UNIT["degree",0.0174532925199433,<br>
>> ? ? ? ? AUTHORITY["EPSG","9108"]],<br>
>> ? ? AUTHORITY["EPSG","4326"]]<br>
>> *Origin = (-180.001488095238102,80.001488095238088)*<br>
>> Pixel Size = (0.002976190476204,-0.002976190476190)<br>
>> Metadata:<br>
>> *? crs#GeoTransform=-180.0000000000 0.0029761905 0.0 80.0000000000 0.0<br>
>> -0.0029761905*<br>
>> ? crs#grid_mapping_name=latitude_longitude<br>
>> ? crs#inverse_flattening=298.257223563<br>
>> ? crs#longitude_of_prime_meridian=0<br>
>> ? crs#long_name=coordinate reference system<br>
>> ? crs#semi_major_axis=6378137<br>
>> ? crs#spatial_ref=GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS<br>
>> 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4326"]]<br>
>> <br>
>> ? crs#_CoordinateAxisTypes=GeoX GeoY<br>
>> ? crs#_CoordinateTransformType=Projection<br>
>> ? lat#axis=Y<br>
>> ? lat#DIMENSION_LABELS=lat<br>
>> ? lat#long_name=latitude<br>
>> ? lat#standard_name=latitude<br>
>> ? lat#units=degrees_north<br>
>> ? lat#_CoordinateAxisType=Lat<br>
>> ? lon#axis=X<br>
>> ? lon#DIMENSION_LABELS=lon<br>
>> ? lon#long_name=longitude<br>
>> ? lon#standard_name=longitude<br>
>> ? lon#units=degrees_east<br>
>> ? lon#_CoordinateAxisType=Lon<br>
>> ? NC_GLOBAL#archive_facility=VITO<br>
>> ? NC_GLOBAL#Conventions=CF-1.6<br>
>> ? NC_GLOBAL#copyright=Copernicus Service information 2019<br>
>> ? NC_GLOBAL#history=Processing line NDVI: 2019-10-22<br>
>> ?<br>
>> NC_GLOBAL#identifier=urn:cgls:global:ndvi300_v1_333m:NDVI300_201910110000_GLOBE_PROBAV_V1.0.1<br>
>> <br>
>> ? NC_GLOBAL#institution=VITO NV<br>
>> ? NC_GLOBAL#long_name=Normalized Difference Vegetation Index<br>
>> ? NC_GLOBAL#orbit_type=LEO<br>
>> ? NC_GLOBAL#parent_identifier=urn:cgls:global:ndvi300_v1_333m<br>
>> ? NC_GLOBAL#platform=Proba-V<br>
>> ? NC_GLOBAL#processing_level=L3<br>
>> ? NC_GLOBAL#processing_mode=Near Real Time<br>
>> ? NC_GLOBAL#product_version=V1.0.1<br>
>> ? NC_GLOBAL#references=http://land.copernicus.eu/global/products/ndvi<br>
>> ? NC_GLOBAL#sensor=VEGETATION<br>
>> ? NC_GLOBAL#source=Derived from EO satellite imagery<br>
>> ? NC_GLOBAL#time_coverage_end=2019-10-20T23:59:59Z<br>
>> ? NC_GLOBAL#time_coverage_start=2019-10-11T00:00:00Z<br>
>> ? NC_GLOBAL#title=10-daily Normalized Difference Vegetation Index 333M:<br>
>> GLOBE 2019-10-11T00:00:00Z<br>
>> ? NDVI#add_offset=-0.079999998<br>
>> ? NDVI#flag_meanings=Missing cloud snow sea background<br>
>> ? NDVI#flag_values={}<br>
>> ? NDVI#grid_mapping=crs<br>
>> ? NDVI#long_name=Normalized Difference Vegetation Index 333M<br>
>> ? NDVI#missing_value=<br>
>> ? NDVI#scale_factor=0.0040000002<br>
>> ? NDVI#standard_name=normalized_difference_vegetation_index<br>
>> ? NDVI#units=<br>
>> ? NDVI#valid_range={}<br>
>> ? NDVI#_FillValue=<br>
>> OGRCT: PROJ >= 4.8.0 features enabled<br>
>> OGRCT: Using locale-safe proj version<br>
>> OGRCT: Source: +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs<br>
>> OGRCT: Target: +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs<br>
>> Corner Coordinates:<br>
>> *Upper Left ?(-180.0014881, ?80.0014881) (180d 0' 5.36"W, 80d 0' 5.36"N)*<br>
>> *Lower Left ?(-180.0014881, -59.9985119) (180d 0' 5.36"W, 59d59'54.64"S)*<br>
>> *Upper Right ( 179.9985119, ?80.0014881) (179d59'54.64"E, 80d 0' 5.36"N)*<br>
>> *Lower Right ( 179.9985119, -59.9985119) (179d59'54.64"E, 59d59'54.64"S)*<br>
>> Center ? ? ?( ?-0.0014881, ?10.0014881) ( ?0d 0' 5.36"W, 10d 0' 5.36"N)<br>
>> Band 1 Block=120960x1 Type=Float32, ColorInterp=Undefined<br>
>> ? NoData Value=0<br>
>> ? Offset: -0.0799999982118607, ? Scale:0.00400000018998981<br>
>> ? Metadata:<br>
>> ? ? add_offset=-0.079999998<br>
>> ? ? flag_meanings=Missing cloud snow sea background<br>
>> ? ? flag_values={}<br>
>> ? ? grid_mapping=crs<br>
>> ? ? long_name=Normalized Difference Vegetation Index 333M<br>
>> ? ? missing_value=<br>
>> ? ? NETCDF_VARNAME=NDVI<br>
>> ? ? scale_factor=0.0040000002<br>
>> ? ? standard_name=normalized_difference_vegetation_index<br>
>> ? ? units=<br>
>> ? ? valid_range={}<br>
>> ? ? _FillValue=<br>
>> GDAL:<br>
>> GDALClose(netcdf:c_gls_NDVI300_201910110000_GLOBE_PROBAV_V1.0.1.nc,<br>
>> this=00000219E2D291F0)<br>
>><br>
>><br>
>><br>
>> _______________________________________________<br>
>> gdal-dev mailing list<br>
>> gdal-dev@lists.osgeo.org<br>
>> <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
>><br>
><br>
> _______________________________________________<br>
> gdal-dev mailing list<br>
> gdal-dev@lists.osgeo.org<br>
> <a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a></div>
</span></font></div>
</body>
</html>