Skip to main content

Hi,

 

I have lots of large raster datasets that I want to resample and save as PNG. The problem is that their rotation is wrong, and trying to modify the angle according to the image properties gives incorrect result. The images are oblique images.

The raster in geotiff format read into FME:

Screenshot 1Doing no rotation gives this result in the final png:

13190_121_060_20220506_Forward 

The image after rotating it.

Screenshot 2 

RasterPropertyExtractor gives _rotation_x=222.30258951435636 and _rotation_y=223.52422211966618. None of these values give the desired result with a straight image.

 

Does anyone have any suggestions? Or is there a simpler way of doing this? Reading the image and disregarding the rotation?

Pixels run NS, EW. So the image is straight. Whats probably happening in you last screenshot is the black surround is black, rather than nodata or it's missing a transparency mask


Pixels run NS, EW. So the image is straight. Whats probably happening in you last screenshot is the black surround is black, rather than nodata or it's missing a transparency mask

Making it nodata results in this:

13190_121_060_20220506_ForwardI want FME to write the resampled image into a straight image. For example, opening the original large geotiff in windows photo viewer shows the image as I want the final result, a rectangle with 90 degree corners:

Screenshot 4


@leif​ Within the RasterPropertyExtractor, it contains a value for the "rotation_x" attribute. This is the current rotation value of your Raster. You can first use an AttributeCreator to create a new attribute called "Rotate_by" and set the value to: 

@Evaluate(-@Value(_rotation_x))

imageBy turning the rotation value negative, we can now undo the rotation. 

Next, add a Rotator transformer, connect it to the AttributeCreator, and set the Rotation Angle parameter to the attribute you just created. When you run the workspace, this should undo the rotation to the Raster. I've attached a sample workspace to demonstrate this. 


@leif​ Within the RasterPropertyExtractor, it contains a value for the "rotation_x" attribute. This is the current rotation value of your Raster. You can first use an AttributeCreator to create a new attribute called "Rotate_by" and set the value to: 

@Evaluate(-@Value(_rotation_x))

imageBy turning the rotation value negative, we can now undo the rotation. 

Next, add a Rotator transformer, connect it to the AttributeCreator, and set the Rotation Angle parameter to the attribute you just created. When you run the workspace, this should undo the rotation to the Raster. I've attached a sample workspace to demonstrate this. 

Hi @danminneyatsaf​,

 

I have tried using your approach, but I get the same result. I could set nodata to hide the black, but keep it to show that the image is not rotated straight.

13190_121_060_20220506_Forward 

Here is the large 441 MB raster in question if anyone want to give it a try:

Raster


Hi @danminneyatsaf​,

 

I have tried using your approach, but I get the same result. I could set nodata to hide the black, but keep it to show that the image is not rotated straight.

13190_121_060_20220506_Forward 

Here is the large 441 MB raster in question if anyone want to give it a try:

Raster

@leif​ if you want to skew the raster so that it fits the shape of a rectangle (square corners), then you can use a combination of the BoundsExtractor to extract the square bounding box of the raster, and then use the RasterGeoreferencer to align the raster to the rectangular bounding box.

One thing to keep in mind is that this may affect accuracy of the raster, but if the desired product is just for visual purposes then this should work fine!

 

I've attached the sample workspace to this comment.

sample_output


Hi @danminneyatsaf​,

 

I have tried using your approach, but I get the same result. I could set nodata to hide the black, but keep it to show that the image is not rotated straight.

13190_121_060_20220506_Forward 

Here is the large 441 MB raster in question if anyone want to give it a try:

Raster

Precisely what I was trying to achieve. Thank you!


Reply