Solved

Clipping WMS layer via polygon and writing it out as an image

  • 25 June 2018
  • 7 replies
  • 233 views

Badge

Hi there,

I've taken some tips form this thread on how to generate a PNG from my WMS layer:

https://knowledge.safe.com/questions/69989/requesting-wmswfs-and-saving-as-image-in-a-file.html

It works pretty good but it generates a PNG containing my entire WMS layer, where I just need a specific area based on a polygon I have. I've tried using the clipper but then the PNG writer generates no output (I'm guessing the clipper is only vector based) and I'm not sure what other transformers I can use to clip my WMS data. Rasters in general is a pretty new area for me in FME.

Any advice will be greatly appreciated!

icon

Best answer by takashi 25 June 2018, 09:33

View original

7 replies

Userlevel 2
Badge +17

Hi @robbie_botha, the Clipper should work on clipping a raster by area(s).

Firstly inspect the raster and the clipper area with FME Data Inspector, to make sure that they have an identical coordinate system and also overlap each other geographically.

Userlevel 2
Badge +17

Hi @robbie_botha, the Clipper should work on clipping a raster by area(s).

Firstly inspect the raster and the clipper area with FME Data Inspector, to make sure that they have an identical coordinate system and also overlap each other geographically.

[Addition] If the WMS dataset doesn't have coordinate system definition, you will have to perform georeferencing before clipping. Have a look at the RasterGeoreferencer transformer.

 

 

Badge

Hi @takashi,

I had a look and spatially the overlap each other perfectly, no issues there.

I did however see that the moment I try to clip it, FME gives me this error message:

PNGRASTER writer: Invalid raster dimensions: 0 rows by 1 columns. Rasters can only be written if they have positive values for both rows and columns. This raster will not be written

Any idea what this could mean? To be clear my WMS is a globe sized layer, and what I'm trying to clip is basically a small town. So technically, it is quite a small fraction of the WMS, but visually looking at it there is plenty of WMS data in my polygon extent when I inspect it.

Userlevel 2
Badge +17

Hi @takashi,

I had a look and spatially the overlap each other perfectly, no issues there.

I did however see that the moment I try to clip it, FME gives me this error message:

PNGRASTER writer: Invalid raster dimensions: 0 rows by 1 columns. Rasters can only be written if they have positive values for both rows and columns. This raster will not be written

Any idea what this could mean? To be clear my WMS is a globe sized layer, and what I'm trying to clip is basically a small town. So technically, it is quite a small fraction of the WMS, but visually looking at it there is plenty of WMS data in my polygon extent when I inspect it.

There could be an invalid raster with no rows has been generated by the Clipper. You can use the RasterPropertyExtractor to extract raster properties including the number of rows/columns and check if the properties are valid.

 

Badge
There could be an invalid raster with no rows has been generated by the Clipper. You can use the RasterPropertyExtractor to extract raster properties including the number of rows/columns and check if the properties are valid.

 

Hi @takashi,

 

Thanks for the advice, I'm learning so many new things :)

 

 

Based on the info from the RasterPropertyExtractor, I can see that before the clipper the rows are 256 and columns 512. After the clipper it is 0 by 1.

 

This leads me to believe the issue is with the reader..? Technically speaking, 256x512 is very tiny, it is just a fully zoomed out view of the layer. I also noticed that if I load the layer into Inspector, zooming does not work, it just stretches the image. In ArcMap for example, I can load in the layer and the data loads based on my view extent, where zooming gives more detail.

 

Any idea how to work around this? Perhaps I need to adjust something in the parameters when I load in the layer?

 

Thanks in advance,

 

 

 

 

 

Badge +2
Hi @takashi,

 

Thanks for the advice, I'm learning so many new things :)

 

 

Based on the info from the RasterPropertyExtractor, I can see that before the clipper the rows are 256 and columns 512. After the clipper it is 0 by 1.

 

This leads me to believe the issue is with the reader..? Technically speaking, 256x512 is very tiny, it is just a fully zoomed out view of the layer. I also noticed that if I load the layer into Inspector, zooming does not work, it just stretches the image. In ArcMap for example, I can load in the layer and the data loads based on my view extent, where zooming gives more detail.

 

Any idea how to work around this? Perhaps I need to adjust something in the parameters when I load in the layer?

 

Thanks in advance,

 

 

 

 

 

Hi @robbie_botha, Looking at the documentation of the WMS reader, it appears if you specify the Map Width and Map Height parameters to larger number of pixels appropriate for the zoom level you need, that might help the situation. Can you please give that a try?

 

Badge

Hi @takashi and @XiaomengAtSafe,

Sorry for not accepting this answer earlier, I got a little distracted.

The clipper did indeed work, I just had some incorrect transformer links in my workspace.

Best regards,

Reply