2

I'm downloading a point-dataset as an x,y,depth .csv-file. I'd like to interpolate these and use them as an nautical navigational chart. The problem arises on interpolating the points into a raster (image below). The dataset also contains islands and parts ashore. I'd like to have a method which sort of clips the raster if no points are in the neighborhood. Even better would be a method which doesn't interpolate at these areas.

enter image description here

In the figure below, I indicated the part in green which yields the perfect result: no interpolation and thus no_data. The parts in red indicate the areas which I want to get rid of. Is there a good method or workflow to yield this desird result?

enter image description here

Edit:
Here is a small sample dataset without islands. I'm still preparing a set with islands in it. Samples

7
  • please, give some information about the interpolation algorithm you used. Which tool are you using GDAL/GRASS ? The first thing I think could be to change the distance weight parameter with a higher value. Commented Sep 25, 2017 at 14:33
  • A different way of interpolation could be a correct answer to my question.. Untill now the QGIS, linear TIN, cubic, IDW with various settings, and also the equivalent options in python numpy all create a result somehow as above. Commented Sep 25, 2017 at 14:36
  • can you send a sample of your data please ? Commented Sep 25, 2017 at 14:38
  • Not sure if it works with your dataset, but you may want to try SAGA Flat detection. It is in Processing | SAGA | Terrain Analysis - Hydrology | Flat detection.
    – Kazuhito
    Commented Sep 25, 2017 at 17:56
  • That could be a solution indeed, thanks. It also makes me think: I can triangulate the data and then get rid of the 'large' polygons. Or is that maybe too quick and dirty? Commented Sep 26, 2017 at 7:44

1 Answer 1

3

One way to avoid an explicit interpolation step* is to simply rasterize your CSV. Then set pixels having depth ≤ 0 to NODATA.

QGIS has a rasterization tool but it only operates on Shapefiles so first you'll convert your CSV to Shapefile.

  1. Add your CSV layer.
  2. In the Layers Panel, right-click to Save As... and give a name to your new Shapefile. If you know the CRS of your CSV, also set it in this dialog.

Now you can rasterize the points.

  1. In the QGIS menu bar, follow Raster > Conversion > Rasterize (Vector to Raster).
    • Input file (shapefile): the shapefile layer you created in step 2.
    • Attribute field: field_3 (the depth)
    • Set an Output file name, and I prefer to use GeoTIFF format.
    • I usually prefer to set "Raster resolution in map units per pixel"; this way you use the same values no matter the extent of your map. Here it helps immensely to know the CRS of your data. In terms of your question, area that's not within "this setting" to the nearest observation will get cropped. Pick a value too small and even water pixels will get cropped out; a value too large and you throw away resolution of your depth readings. On your data, I chose 50 x 50 and you'll see below that it did alright, not perfect.

Finally, to crop away raster values less-than-or-equal-to 0. You have a couple options here:

  1. Convert these to NODATA following this method. NODATA values will not be painted by QGIS. Or...
  2. As a hack, if you just want a pretty map but care less about the integrity of your raster file, you can skip NODATA conversion (step 4) and tell QGIS to paint values ≤0 with full transparency. In the raster layer's Style properties, set colors to value ranges, making sure that the color 0 has opacity:

enter image description here

Below are my results. You can see that resolution 50x50 still leaves a few missing pixels in the river, because there were simply no depth readings within 50 map units of those places. The solution is set more map units per pixel in step 3 at the risk of smoothing out other depth readings, or to interpolate and find another method to clip unwanted areas.

enter image description here

* Some sort of interpolation is necessary, strictly speaking, to get an infinitesimally small point observation to extend to cover any small area: even rasterization technically "interpolates" a point value to cover its 50-unit x 50-unit pixel.

1
  • Actually this is quite a good solution. Rasterizing instead of interpolation, why haven't I thought about that before.. Will try the suggested workflow, because I don't think the small gaps are of any importance and maybe can be fixed quite easily. Commented Mar 7, 2018 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.