What is the raster cell size? RasterPropertyExtractor --> _spacing_x / y
You're not doing anything wrong but when clipping rasters FME is returning whole pixels (which makes sense, otherwise clipping would involve resampling).
You're not doing anything wrong but when clipping rasters FME is returning whole pixels (which makes sense, otherwise clipping would involve resampling).
@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?
@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?
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:
- 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.
- 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)
@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?
same problem, would you have any resolution?
Hello @thanatej , thanks for your question. Generally, raster extents will always be > than vector extents because of the nature of the grid data structure. Could you tell me what are you trying to solve? I think the best approach is to resample first, then clip (as suggested above). I suppose you could attempt to rasterize the polygon to make a pixel mask, but depends on the context of your data! You might have come across this resource before, but I thought I'd include it anyways - goes through a lot of raster processes in FME: https://www.safe.com/blog/2014/07/raster-master/. Hope this helps, Kailin.