Question

How to clip a raster with clipper's extend?

  • 8 September 2016
  • 19 replies
  • 100 views

Hi,

I want to cut a raster with shp file, and the result raster will have the extent of the clipper's instead of the clippee's. (consider null or nodata as filled up)


19 replies

Userlevel 4

Not sure I fully understand, but is it perhaps the RasterTiler that you are looking for?

Not sure I fully understand, but is it perhaps the RasterTiler that you are looking for?

no, not raster tiler.

 

When I clip a raster with shp polygon, I want the raster will take the polygon extend if there are places the raster it was not covered, then the result can be filled up with 0.

 

 

If you can understand me better now.

 

Userlevel 2
Badge +12

The Clipper transformer should be able to do that. Shape as Clipper, raster as Clippee, output from Inside (or in older versions Clipped_Inside.

Make sure both data sets are in the same coordinate system.

Badge +22

Use the clipper, make sure Preserve Clippee Extents is set to No. You can explicitly set the NoData value before hand by using the RasterBandNoDataSetter, if you don't it defaults to 0

Userlevel 2
Badge +17

Does this screenshot illustrate your requirement?

Two green checkerboards are original rasters, and red squares represent the extents of resulting rasters i.e. clippers' extents.

Does this screenshot illustrate your requirement?

Two green checkerboards are original rasters, and red squares represent the extents of resulting rasters i.e. clippers' extents.

yes! Each read polygon is a tiled raster. So it will end up in 7 small rasters with same extents and same resolution.
Userlevel 2
Badge +17
yes! Each read polygon is a tiled raster. So it will end up in 7 small rasters with same extents and same resolution.
The screenshot was created by this workspace (FME 2016.1.1): clip-raster-with-clipper-extent-demo.fmw

 

Assuming that the clippers (tiles) have column index and row index which can be used to identify each tile.

  1. BoundsExtractor: Extract extents (xmin, ymin, xmax, ymax) for each clipper.
  2. Clipper: Merge clipper's extents to clipped rasters.
  3. MapnikRasterizer: Render the clipped rasters onto clipper's extents.
Userlevel 2
Badge +17
yes! Each read polygon is a tiled raster. So it will end up in 7 small rasters with same extents and same resolution.
If the number of tiles is very large, it might be better to sort the clipped rasters by column and row indices and set 'Yes' to the 'Input is Ordered by Group' parameter in the MapnikRasterizer.

 

If the number of tiles is very large, it might be better to sort the clipped rasters by column and row indices and set 'Yes' to the 'Input is Ordered by Group' parameter in the MapnikRasterizer.

 

Solved and thanks!! ^^
Badge
Solved and thanks!! ^^
Hello,

 

I have similar problem.

 

I want to clip a raster (MDT=1 band) -generated from 2 asc files (no problem)- to many tif tiles following exact coordinates extracted from a shapefile. If tiles are smaller than the extend of shape, they should be filled with any value but the tfw of tiles should be exactly the same the coordinate of the clipper (shape).

 

When I appy Clipper tranformer, the coordinates are not exactly the same of the shape. When I add also Mapnik Rasterizer, the results are tiles on coordinates ok following the shape, but they are RGB type and no data values in all the tiles (empty tiles). In attachment the model. thanks

 

mosaico.jpg

 

mosaic-clip.fmw

 

Badge

Hello,

I have a similar problem but I havent solved it yet.

I have a raster 1 band extracted from asc files (no problem). I want to tile it in different tiles following coordinates extended of a shapefile. If the tiles dont cover the shape extend they should be filled with any value but the coordinates should be the same than the shapefile (clipper).

If I apply only Clipper tranformer the tiles are ok but the coordinates extend dont follow the shape extend because the tiles are smaller and dont fill the no data.

If I also add Mapnik rasterizer the coordinates of tiles are ok but the tiles are RGB and empty.

Many thanks!

mosaic-clip.fmw

mosaico.jpg

Userlevel 2
Badge +17

Hello,

I have a similar problem but I havent solved it yet.

I have a raster 1 band extracted from asc files (no problem). I want to tile it in different tiles following coordinates extended of a shapefile. If the tiles dont cover the shape extend they should be filled with any value but the coordinates should be the same than the shapefile (clipper).

If I apply only Clipper tranformer the tiles are ok but the coordinates extend dont follow the shape extend because the tiles are smaller and dont fill the no data.

If I also add Mapnik rasterizer the coordinates of tiles are ok but the tiles are RGB and empty.

Many thanks!

mosaic-clip.fmw

mosaico.jpg

If I understood your requirement correctly, the attached workspace might help you.

 

clip-raster-demo.fmwt (FME 2018.0.1.1)
Badge

Hello,

I have a similar problem but I havent solved it yet.

I have a raster 1 band extracted from asc files (no problem). I want to tile it in different tiles following coordinates extended of a shapefile. If the tiles dont cover the shape extend they should be filled with any value but the coordinates should be the same than the shapefile (clipper).

If I apply only Clipper tranformer the tiles are ok but the coordinates extend dont follow the shape extend because the tiles are smaller and dont fill the no data.

If I also add Mapnik rasterizer the coordinates of tiles are ok but the tiles are RGB and empty.

Many thanks!

mosaic-clip.fmw

mosaico.jpg

What are the Mapnik rasterizer parameteres I should consider? Thanks, mapnik.jpg

 

 

Userlevel 2
Badge +17
What are the Mapnik rasterizer parameteres I should consider? Thanks, mapnik.jpg

 

 

The MapnikRasterizer generate RGB or RGBA image raster, so it's hard to apply to your case - i.e. handling 1 band Numeric raster. Please see my solution attached in the previous comment.

 

 

Badge
If I understood your requirement correctly, the attached workspace might help you.

 

clip-raster-demo.fmwt (FME 2018.0.1.1)
Many thanks for your reply but I can´t achieve the results expected. In attachment my data to be used. The results should be 8 tiles with the same extension than the shape (results.jpg)

 

data.zip

 

 

Userlevel 2
Badge +17
If I understood your requirement correctly, the attached workspace might help you.

 

clip-raster-demo.fmwt (FME 2018.0.1.1)
Since your rasters have Nodata (= -9999), you will have to set -9999 to these parameters.

 

  • 3DForcer: the Elevation parameter
  • NumericRasterize: the Background Value parameter
And also, set Yes to the Fill Background With Nodata parameter in the NumericRasterizer.

 

Then, remove the RasterBandNodataSetter from the workflow.

 

 

Userlevel 2
Badge +17
If I understood your requirement correctly, the attached workspace might help you.

 

clip-raster-demo.fmwt (FME 2018.0.1.1)
An example: clip-raster-with-clippers-extents.fmwt (FME 2018.0.1.1)

 

 

Badge +2

Also make sure to have the same value for the Group By attritube on both raster and clipper(s) if you use the clipper in Group By mode.

Badge +1

I believe my raster clip tutorial answers this exact question: https://youtu.be/K6F4jAozlVs

Reply