[GRASS-user] raster pixel value

Markus Metz markus.metz.giswork at gmail.com
Thu Mar 14 09:07:49 PDT 2019


On Thu, Mar 14, 2019 at 3:16 PM Nikos Alexandris <nik at nikosalexandris.net>
wrote:
>
> Following up, why are there differences between GDAL and GRASS GIS in
> the following example?
>
> This ftp://ftp.soilgrids.org/data/aggregated/5km/OCDENS_M_sl1_5km_ll.tif
> raster map, subject to `gdalinfo`:
> ```
> gdalinfo OCDENS_M_sl1_5km_ll.tif -nogcp -nomd -norat -noct -nofl
> Driver: GTiff/GeoTIFF
> Files: OCDENS_M_sl1_5km_ll.tif
> Size is 7200, 2987
> Coordinate System is:
> GEOGCS["WGS 84",
>     DATUM["WGS_1984",
>         SPHEROID["WGS 84",6378137,298.257223563,
>             AUTHORITY["EPSG","7030"]],
>         AUTHORITY["EPSG","6326"]],
>     PRIMEM["Greenwich",0],
>     UNIT["degree",0.0174532925199433],
>     AUTHORITY["EPSG","4326"]]
> Origin = (-180.000000000000000,87.370000000000005)
> Pixel Size = (0.050000000000000,-0.050000000000000)
> Corner Coordinates:
> Upper Left  (-180.0000000,  87.3700000) (180d 0' 0.00"W, 87d22'12.00"N)
> Lower Left  (-180.0000000, -61.9800000) (180d 0' 0.00"W, 61d58'48.00"S)
> Upper Right ( 180.0000000,  87.3700000) (180d 0' 0.00"E, 87d22'12.00"N)
> Lower Right ( 180.0000000, -61.9800000) (180d 0' 0.00"E, 61d58'48.00"S)
> Center      (   0.0000000,  12.6950000) (  0d 0' 0.00"E, 12d41'42.00"N)
> Band 1 Block=7200x1 Type=Int16, ColorInterp=Gray
>   NoData Value=-32768
> ```
>
> and GRASS GIS
> ```
> # create a new Location
> grass -c OCDENS_M_sl1_5km_ll.tif /geoyeux/grassdb/global/soil_grids/
>
> # projection info
> g.proj -g
>
> name=WGS 84
> datum=wgs84
> ellps=wgs84
> proj=ll
> no_defs=defined
> epsg=4326
> unit=degree
> units=degrees
> meters=1.0
>
> # raster info
> r.info -g OCDENS_M_sl1_5km_ll
>
> north=87.37
> south=-61.98
> east=180
> west=-180
> nsres=0.05
> ewres=0.05
> rows=2987
> cols=7200
> cells=21506400
> datatype=CELL
> ncats=0
>
> # report non-NULL cells and their x, y grid location
> r.stats OCDENS_M_sl1_5km_ll -n -x > stats_x
> ```
>
> Comparing a few single pixels via:
> ```
> while read LINE;do
>     set -- $LINE
>     echo " ($1,$2)
>     echo "GDAL:  $(gdallocationinfo -valonly OCDENS_M_sl1_5km_ll.tif $1
$2)"
>     echo "GRASS: $3"
>     echo
> done < stats_x_head
> ```
>
> gives
> ```
>  (2930,77)
> GDAL:  2090
> GRASS: 2096
>
>  (2931,77)
> GDAL:  2055
> GRASS: 2090
>
>  (2932,77)
> GDAL:  2063
> GRASS: 2055
>
>  (2933,77)
> GDAL:  2093
> GRASS: 2063
>
>  (2934,77)
> GDAL:  2240
> GRASS: 2093
>
>  (2935,77)
> GDAL:  2332
> GRASS: 2240
>
>  (2936,77)
> GDAL:  2296
> GRASS: 2332
>
>  (2937,77)
> GDAL:  2253
> GRASS: 2296
>
>  (2938,77)
> GDAL:  2179
> GRASS: 2253
>
>  (2939,77)
> GDAL:  2115
> GRASS: 2179
> ```
>
> Why these differences?

With r.stats -x, indexing starts with 1 (first row is 1).
With gdallocationinfo, indexing starts with 0 (first row is 0).

Markus M
>
> Nikos
>
>
> # meta
>
> GRASS 7.7.svn (2019)
> libgis Revision: 74118
> libgis Date: 2019-02-21 10:38:28 +0100 (Thu, 21 Feb 2019)
>
> GDAL 2.3.1, released 2018/06/22
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20190314/0ba55973/attachment.html>


More information about the grass-user mailing list