Comments and answers for "Clipping raster files accuracy" https://knowledge.safe.com/questions/87160/clipping-raster-files-accuracy.html The latest comments and answers for the question "Clipping raster files accuracy" Comment by redgeographics on redgeographics's comment https://knowledge.safe.com/comments/87344/view.html

From what I gathered gdalwarp not only clips but also resamples the image. You can comfirm this by checking the info on the original raster (specifically the pixel size).

Essentially there's 2 ways to handle clipping a raster that we're seeing here:

  1. The FME Way: take all original pixels that are fully inside the clip polygon and output those. Unless your clip polygon lines up exactly with the pixel edges the result will be a little bit smaller than the clip polygon.
  2. The GDAL way: take all original pixels that are fully or partially inside the clip polygon, then resample them so that the new pixels line up exactly with the clip polygon.

The benefit of the FME way is that every resulting pixel still matches with the original one. With the GDAL way I'm not so sure.

If you want FME to behave in the GDAL way you'll have to figure out the current pixel size and then resample the raster so that its new pixels line up perfectly with the clip polygon before clipping. To be honest, I can't really say how to do that right now :) (but I'm jetlagged)

Thu, 21 Feb 2019 15:02:03 GMT redgeographics
Comment by witos on witos's answer https://knowledge.safe.com/comments/87341/view.html

@redgeographics Thanks for the answer but I have a question here:

I used also other tool like presented here:

https://gis.stackexchange.com/questions/200407/merging-gdal-tiles-and-crop-via-bounding-box


gdalwarp command that I used is:

gdalwarp.exe -of GTiff -co COMPRESS=LZW -cutline clipper.kml -crop_to_cutline tiffFilesToBeClippedAndMerged.vrt result.t

and the gdal info for file generated this way is:

Origin = (540000.000000000116415,6170000.000000001862645) Pixel Size = (0.699986000280060,-0.699986000280581) Metadata: AREA_OR_POINT=Area Image Structure Metadata: COMPRESSION=LZW INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( 540000.000, 6170000.000) ( 9d38' 9.67"E, 55d40'27.01"N) Lower Left ( 540000.000, 6160000.000) ( 9d38' 4.44"E, 55d35' 3.56"N) Upper Right ( 550000.000, 6170000.000) ( 9d47'42.04"E, 55d40'23.68"N) Lower Right ( 550000.000, 6160000.000) ( 9d47'35.50"E, 55d35' 0.23"N) Center ( 545000.000, 6165000.000) ( 9d42'52.91"E, 55d37'43.71"N) 


while for raster processed with fme like I described above it is:


Origin = (540000.000039999955334,6169999.800039999186993) Pixel Size = (0.700000000000000,-0.699951000979980) Metadata: AREA_OR_POINT=Area Image Structure Metadata: COMPRESSION=LZW INTERLEAVE=PIXEL Corner Coordinates: Upper Left ( 540000.000, 6169999.800) ( 9d38' 9.67"E, 55d40'27.01"N) Lower Left ( 540000.000, 6160000.300) ( 9d38' 4.44"E, 55d35' 3.57"N) Upper Right ( 550000.200, 6169999.800) ( 9d47'42.05"E, 55d40'23.67"N) Lower Right ( 550000.200, 6160000.300) ( 9d47'35.51"E, 55d35' 0.24"N) Center ( 545000.100, 6165000.050) ( 9d42'52.92"E, 55d37'43.72"N)


So I wonder what can I do in FME to have the same results as I have using GDAL?


Thu, 21 Feb 2019 14:33:35 GMT witos
Comment by witos on witos's comment https://knowledge.safe.com/comments/87167/view.html

hello @nielsgerrits
it is both x/y 0.7

Tue, 19 Feb 2019 12:06:56 GMT witos
Answer by redgeographics https://knowledge.safe.com/answers/87165/view.html < div class = " fr-view clearfix " > < p >你们#39;re not doing anything wrong but when clipping rasters FME is returning whole pixels (which makes sense, otherwise clipping would involve resampling).

Tue, 19 Feb 2019 11:52:49 GMT redgeographics
Comment by nielsgerrits https://knowledge.safe.com/comments/87163/view.html

What is the raster cell size? RasterPropertyExtractor --> _spacing_x / y

Tue, 19 Feb 2019 11:41:32 GMT nielsgerrits