Question

Intersect 2 raster file


Badge +5

Hi,

I am making landuse change of 2 times but the data vector is so big.

So I want to convert raster and make matrix landuse change in FME. Firstly, I will convert vector to raster and then find a intersect raster function.

But I don't find the function to intersect raster. With vector, I used AreaOnAreaOverlayer function.

Could you show me the function to intersect raster?

Thank you


24 replies

Badge +2

Hi,

Since, you want only intersections by using AreaOnAreaOverlayer then use BoundingBoxReplacer to make raster to vector on-the-fly.

At any point you can take raster by using parallel connections.

Pratap

Userlevel 2
Badge +17

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Userlevel 4
Badge +13

If you want to work entirely in Raster, you can combine rasters using the RasterExpressionEvaluator. We recently explored this type of approach on a webinar -- check the recording at https://www.safe.com/webinars/choosing-the-right-transformer-for-your-data-challenge/ and in particular, jump to the "Rad Radar" bookmark in the video -- it is very similar to what you want to do.

Badge +5

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Hi @takashi, my targets are:

 

1. Convert polygon to raster

 

2. Intersect 2 rasters to decrease memory because my data's so big

 

Normal, I intersect 2 vectors use AreaOnAreaOverlayer function. Now I want to use raster to intersect.

 

Could you show me how to the way to intersect raster?

 

Thank you
Userlevel 2
Badge +17

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

My intention is very simple. Create intersecting area from the two polygons that represent raster extents, clip the rasters by the area. The resulting rasters should be your desired "intersected" rasters, if I understood the requirement correctly.

 

 

Badge +5

If you want to work entirely in Raster, you can combine rasters using the RasterExpressionEvaluator. We recently explored this type of approach on a webinar -- check the recording at https://www.safe.com/webinars/choosing-the-right-transformer-for-your-data-challenge/ and in particular, jump to the "Rad Radar" bookmark in the video -- it is very similar to what you want to do.

Thank you.

 

In my case, I need 2 steps:

 

1. Convert 2 layers polygon to raster

 

2. Intersect 2 raster

 

 

Actually, I can do it in vector file. But my vector is so big. So I want to convert to raster to intersect, it's not heavy.

 

Could you tell me how is the way to do it?

 

Thank you

 

 

Badge +5

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Hi @takashi

 

My target is here:

 

Userlevel 2
Badge +17

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Are you using the term "intersect" with what meaning?

 

I assume that the two rasters have different extents and you need to get their "intersection" (i.e. overlapped part).

 

If my assumption was correct, there is no transformer to directly "intersect" two or more rasters, such as the AreaOnAreaOverlayer for polygon features. However, you can create extents (polygons) of the rasters, get intersected area of them with the AreaOnAreaOverlayer, and then clip the rasters by the intersected area with the Clipper. The result would be equivalent to the "intersection" (overlapped part) of the two rasters. Isn't it your desired result?

 

If the two rasters originally have the same extents, and you need just to calculate difference between them for each cell, consider using the RasterExpressionEvaluator (Mode: Two Rasters). Although I don't think it's "intersect" operation...

 

 

Badge +5

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Hi @takashi,

 

"Intersect" mean " AreaOnAreaOverlayer.

 

I attached demo data. But I got error when runing rasterExtentcoeroer.

 

I have 2 layer polygon 2010_test (Use field ldlr_2010) and 2015_test (use field ld_2015) to convert polygon to raster. But i got errors.

 

 

Could you tell me why?

 

raster.fmwt

 

Userlevel 2
Badge +17

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

Send rasters to the RasterExtentsCoercer. I thought you have already created rasters.

 

What is your question - how to create raster from the polygons, how to intersect rasters, or both?

 

 

Badge +5

Hi @hoa_le, you can use the RasterExtentsCoercer (Extents Type: Raster Extents) or the BoundingBoxReplacer to convert the rasters to rectangle polygons which represent their extents. You can then use the AreaOnAreaOverlayer and the Tester to get the overlapping area, and clip the original rasters by the area.

 

Hi @takashi,

 

My question is both. Step 1: creat raster from polygon, step 2: intersect raster
Userlevel 2
Badge +17

You can use the 3DForcer and the NumericRasterizer to convert the polygons to rasters. However, you will have to determine these things at first to set the parameters in those transformers.

  • Which attribute value do you use as cell value in the resulting raster?
  • How large cell spacings (width and height of each cell) in the resulting raster are preferable (in the ground units)?
Userlevel 2
Badge +17

You can use the 3DForcer and the NumericRasterizer to convert the polygons to rasters. However, you will have to determine these things at first to set the parameters in those transformers.

  • Which attribute value do you use as cell value in the resulting raster?
  • How large cell spacings (width and height of each cell) in the resulting raster are preferable (in the ground units)?
For instance, this workflow creates two 1-band numeric rasters (cell value = "volume_per", cell-spacing = 0.1/3600 degrees = 0.1 seconds) from the two Shapefile datasets.

 

Please modify parameters (attribute to be used as cell value, cell spacing, background value, etc.) appropriately.

 

Since the resulting rasters have the same extents and resolution, you can calculate change between two rasters for each cell with the RasterExpressionEvaluator, without performing any "intersection" operation.

 

Badge +5

You can use the 3DForcer and the NumericRasterizer to convert the polygons to rasters. However, you will have to determine these things at first to set the parameters in those transformers.

  • Which attribute value do you use as cell value in the resulting raster?
  • How large cell spacings (width and height of each cell) in the resulting raster are preferable (in the ground units)?
Hi @takashi

 

I made workflow the same in the bellow. But in RasterExpresstionEvaluator I don't use the parameters. I attached my workspace here:

 

lc.fmwt
Userlevel 2
Badge +17
Hi @takashi

 

I made workflow the same in the bellow. But in RasterExpresstionEvaluator I don't use the parameters. I attached my workspace here:

 

lc.fmwt
I don't know what your desired result. You will have to think what expression is reuqired, by yourself.

 

Also, check carefully parameters in the NumericRasterizer. At least you have to set "fme_feature_type" to the Group By parameter.

 

If you project the polygons onto a specific coordinate system, the ground extents (xmin, ymin, xmax, xmax) should also be projected onto the same coordinate system.

 

Userlevel 2
Badge +17
Hi @takashi

 

I made workflow the same in the bellow. But in RasterExpresstionEvaluator I don't use the parameters. I attached my workspace here:

 

lc.fmwt
Firstly connect Inspectors to the end of this workslow and run, to check if this creates your desired rasters (check cell values, extents, resolutions, etc.).

 

 

Badge +5

You can use the 3DForcer and the NumericRasterizer to convert the polygons to rasters. However, you will have to determine these things at first to set the parameters in those transformers.

  • Which attribute value do you use as cell value in the resulting raster?
  • How large cell spacings (width and height of each cell) in the resulting raster are preferable (in the ground units)?
Hi @takashi

 

Normally, with layer is less polygon. I use model the same the bellow.

 

Now I have to work with more over 80,000 records, so I see FME can't do this. I want to convert polygon to raster to descrease memory. So I want to convert to raster and make model look like here

 

poly.png

 

Userlevel 2
Badge +17
Hi @takashi

 

Normally, with layer is less polygon. I use model the same the bellow.

 

Now I have to work with more over 80,000 records, so I see FME can't do this. I want to convert polygon to raster to descrease memory. So I want to convert to raster and make model look like here

 

poly.png

 

There is no operations for rasters similar to the AreaOnAreaOverlayer. What result do you want to get from the two rasters?

 

 

Badge +5
There is no operations for rasters similar to the AreaOnAreaOverlayer. What result do you want to get from the two rasters?

 

 

I want a layer polygon including 2 field code 2014 and 2018 in a layer to know what's change from 2014 to 2018.

 

 

Userlevel 2
Badge +17
There is no operations for rasters similar to the AreaOnAreaOverlayer. What result do you want to get from the two rasters?

 

 

I think the AreaOnAreaOverlayer works fine even if there were more than 80,000 records. Why not try it first? Have you encountered any issue on the AreaOnAreaOverlayer?

 

 

Userlevel 4
Badge +13
There is no operations for rasters similar to the AreaOnAreaOverlayer. What result do you want to get from the two rasters?

 

 

Actually, if you do a RasterBandCombiner from 2 numeric rasters that overlap each other and have same pixel size, you can then do a RasterExpressionEvaluator to effectively do pixel by pixel overlay.

 

 

Badge +5
I think the AreaOnAreaOverlayer works fine even if there were more than 80,000 records. Why not try it first? Have you encountered any issue on the AreaOnAreaOverlayer?

 

 

Hi @takashi,

 

I don't know why when I read 2 layers in the .gdb and overlay them. I got error, reject it. But I read them and open inspector, it's view ok.

Badge +5
Actually, if you do a RasterBandCombiner from 2 numeric rasters that overlap each other and have same pixel size, you can then do a RasterExpressionEvaluator to effectively do pixel by pixel overlay.

 

 

Yes. Thank you

 

 

Userlevel 2
Badge +17
I think the AreaOnAreaOverlayer works fine even if there were more than 80,000 records. Why not try it first? Have you encountered any issue on the AreaOnAreaOverlayer?

 

 

In your screenshot, I can see that the rejected polygon has only three coordinates. That is, the polygon has no area. It's the reason why the polygon has been rejected.

 

You can connect an Inspector to the Rejected port and run the workspace, in order to check what features would be rejected.

 

Reply