2

I am currently generating a raster from point data and applying inverse distance algorithm. This image is then cut with:

gdalwarp -cutline <<src shapefile>> -crop_to_cutline -srcnodata 0 results_in.tiff results_out.tiff

Is there a way to cut the output to the extremities of the original data source file rather than a shapefile?

EDIT : gdal_grid command

gdal_grid -a invdist:power=2:smoothing=0.001:radius1=0.0005:radius2=0.0005 -of GTiff -zField z_value -ot Float64 -l data VRT.vrt EM_RESULTS.tiff
2
  • So, I am unable to test this directly since I am on my iphone in a bus right now. I checked the gdalwarp documentaion, and it looks like the output extent is tied specifically to the cutline when you use the -crop_to_cutline option. I would try removing that option, which should cause it to default to the intersection of all input files. (in this case there is only the one input file so it should default to that) Give that a try and let me know what happens. If it does not solve your problem I will play with it tonight when I get home.
    – G.Oxsen
    Nov 26 '13 at 21:23
  • The data is extrapolated beyond the boundary prior to the GDALwarp so in hindsight the issue is perhaps with my gdalgrid command edited as above
    – JSz
    Nov 28 '13 at 9:23
3

gdalwarp utility has a target extent option:

-te xmin ymin xmax ymax:
set georeferenced extents of output file to be created (in target SRS).

Instead, gdal_grid has two options, one for each axis:

-txe xmin xmax:
Set georeferenced X extents of output file to be created.

-tye ymin ymax:
Set georeferenced Y extents of output file to be created.

EDIT
So if you want to cut the interpolated raster with the boundary (and not the extent) of the region defined by your points, i.e. a convex (or concave) hull, you have to calculate it before. Actually, it's only possible to calculate the convex hull with GDAL > 1.10 compiled with SQLite and SpatiaLite support. In the next future (with SpatiaLite 4.0 support, GDAL 1.10.2?), it will be possible to calculate the concave hull too.

Convex hull:

ogr2ogr convex_hull.shp points.shp -dialect SQLite -sql "SELECT ST_ConvexHull(ST_Collect(geometry)) FROM points"

Finally, you can use convex_hull.shp as cutline in gdalwarp and so obtain the result.

4
  • This will prevent data extrapolating beyond an X and Y however not beyond the boundary of the point cloud. In essence I will need to generate a boundary first, interpolate ( which will extrapolate beyond my original point data ) and then clip to the originally created boundary.
    – JSz
    Nov 29 '13 at 12:15
  • Unfortunately, there's not other quick way to accomplish this task. First interpolate with gdal_grid, then cut with gdalwarp using the convex (or concave) hull of your points as cutting layer (boundary). Alternatively, you could define your boundary as a mask (raster) layer and then apply it with gdal_translate using the -mask option. Nov 29 '13 at 12:51
  • Its the generation of the concave/convex hull which is being the tricky part. If you know a way to generate a shape polygon from point data ( csv or shp ) then that would be the solution. It doesn't appear to be that simple from GDAL / OGR tools.
    – JSz
    Nov 29 '13 at 15:43
  • I've updated the answer. Hope this helps. Nov 29 '13 at 16:30

Your Answer

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

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