2

I have problems with strange artifacts occuring when rendering GeoTIFFs using gdal_grid with the linear interpolation algorithm.

Input files

I have a samples.csv file with some geo data samples:

latitude,longitude,value
53.8035355,17.020874,19.43
53.803688,17.0284729,19.36
53.8038445,17.0360718,19.38
53.8040047,17.0436707,19.38
53.8041649,17.0513,19.45
53.8043213,17.0588989,19.47
53.8044815,17.0664978,19.55
...

For this data, I created a simple samples.vrt file:

<OGRVRTDataSource>
  <OGRVRTLayer name="samples">
    <SrcDataSource>samples.csv</SrcDataSource>
    <GeometryType>wkbPoint</GeometryType>
    <LayerSRS>WGS84</LayerSRS>
    <GeometryField encoding="PointFromColumns" x="longitude" y="latitude" z="value" />
  </OGRVRTLayer>

I also have a colormap file for the data (for use with gdaldem):

-9999.0 0:0:0:0
-28 245:245:245:255
-26 235:235:235:255
-24 225:225:225:255
-22 190:190:190:255
-20 130:130:130:255
...

I uploaded the input files here.

Procedure

First, I create a GeoTIFF with gdal_grid:

gdal_grid \
  -ot Float64 \
  -of GTiff \
  -txe 16.870876 19.691624 \
  -tye 54.980014 53.746311 \
  -outsize 682 512 \
  -a linear:radius=0.0:nodata=-9999.0 \
  samples.vrt samples.tiff

Then I colorize the tiff with gdaldem:

gdaldem \
  color-relief \
  samples.tiff colormap samples-colored.tiff

Result

If I use the linear interpolation algorithm, I get the following result:

(Notice the red bars at the top.)

enter image description here

If I switch to the nearest algorithm, e.g.

-a nearest:radius1=0.01:radius2=0.01:nodata=-9999.0

the output image looks fine:

enter image description here

It is also fine if I use the linear algorithm, but flip the image by specifying -tye in the reverse order, i.e. -tye 53.746311 54.980014 - so maybe the problem is somehow related to the negative pixel dimensions.

In my tests, I used GDAL 2.3.0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.