[gdal-dev] gdal_grid does not work in cron but works in terminal

davorinbajic davorinbajic at gmail.com
Tue Jun 4 02:51:51 PDT 2019


I use the gdal_grid interpolation command. When I work in the terminal
everything works perfectly. However, when I try to run the command in the
bash script from cron then it does not work.

Bash script (/root/interpolation/interpolation.sh):

#!/bin/bash

gdal_grid -ot Float64 -of GTiff -outsize 750 750 -a
invdist:power=2.0:smoothing=0.0:radius1=0.08:radius2=0.08:angle=0.0:max_points=0:min_points=0
/root/interpolation/today.vrt /root/interpolation/out/today.tif

I also tried the path to gdal_grid

#!/bin/bash

/usr/bin/gdal_grid -ot Float64 -of GTiff -outsize 750 750 -a
invdist:power=2.0:smoothing=0.0:radius1=0.08:radius2=0.08:angle=0.0:max_points=0:min_points=0
/root/interpolation/today.vrt /root/interpolation/out/today.tif

Virtual file (/root/interpolation/today.vrt)

<OGRVRTDataSource>
<OGRVRTLayer name="today">
    <SrcDataSource>/root/interpolation/today.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
<LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="X" y="Y" z="eto"/>
</OGRVRTLayer>

CSV (/root/interpolation/today.csv)

id,X,Y,eto
1,17.11400986,43.59461212,5.284
2,16.01515388,44.38002777,5.636
3,19.3653698,44.19543839,6.823
4,17.25690269,44.1989975,6.041
5,18.53639221,43.60323715,6.452
6,16.9213295,45.12902069,6.95
...

CRON

PATH='/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin'

39 10 * * * /root/interpolation/interpolation.sh 

Error

Usage: gdal_grid [--help-general] [--formats]
[-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
      CInt16/CInt32/CFloat32/CFloat64}]
[-of format] [-co "NAME=VALUE"]
[-zfield field_name]
[-a_srs srs_def] [-spat xmin ymin xmax ymax]
[-clipsrc <xmin ymin xmax ymax>|WKT|datasource|spat_extent]
[-clipsrcsql sql_statement] [-clipsrclayer layer]
[-clipsrcwhere expression]
[-l layername]* [-where expression] [-sql select_statement]
[-txe xmin xmax] [-tye ymin ymax] [-outsize xsize ysize]
[-a algorithm[:parameter1=value1]*]    [-q]
<src_datasource> <dst_filename>

Available algorithms and parameters with their's defaults:
Inverse distance to a power (default)
   
invdist:power=2.0:smoothing=0.0:radius1=0.0:radius2=0.0:angle=0.0:max_points=0:min_points=0:nodata=0.0
Moving average
    average:radius1=0.0:radius2=0.0:angle=0.0:min_points=0:nodata=0.0
Nearest neighbor
    nearest:radius1=0.0:radius2=0.0:angle=0.0:nodata=0.0
Various data metrics
    <metric name>:radius1=0.0:radius2=0.0:angle=0.0:min_points=0:nodata=0.0
    possible metrics are:
        minimum
        maximum
        range
        count
        average_distance
        average_distance_pts

FAILURE: Neither -sql nor -l are specified

Note that it works in the terminal but it does not work in cron. Does anyone
know what the problem is?




--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html


More information about the gdal-dev mailing list