Skip to main content
Solved

Python Raster API - Unable to create a RED8 band


Forum|alt.badge.img

I have been struggling with this issue for two days. In summary, I am reading in some locations with the intent of creating mapping tiles only for those locations (the territory I am covering is huge, so an overall raster + raster tiler is not an option). The flow of the workspace is as follows:

  1. Read the "Sample.csv"
  2. Calculate the tile boundaries and tiles index numbers based in the PyTileMaker script
  3. Sort the tiles so that similar tiles are grouped (in TileSorter)
  4. Generate the tiles bands, raster and points-in-tile in PyMakePoints

In the last step, I need to produce 4 bands (as in RGBA). The raster and bands are 256x256. I can generate the 4 bands if I use FME_INTERPRETATION_UINT8 for the band properties and a UInt8BandTilePopulator to generate the band. Unfortunately, the resulting raster has no idea which band is which in terms of RGB or alpha.

So it seems logical that one would generate bands with the proper interpretation property, such as FME_INTERPRETATION_RED8 and a band populator for the RED8 type. But that does not work, it results in "Failed to create FMEBand." error message. I tried to put an exception catcher around the offending statement, but it contained the same message.

For the sake of completeness, I also tried to generate one band only with the type FME_INTERPRETATION_RGBA32, but that failed with the similar message.

I have included a small workspace and data file that illustrate the problem.

--------------------------------------------------------------------------------------

On another (albeit related topic)... The API documentation suggests that one does not need to specify a noValue parameter when calling the band tile populator. That is not accurate. If one omits the noValue parameter in fmeobjects.FMEBand(), the function executes but the workspace fails with the message that it cannot write to the workspace file. If one sets the noValue to "None", the call returns "Failed to create FMEBand". Just thought this may be useful to some people :-)

Frederic

Workspace and data file:

Best answer by carsonlam

The "Failed to create FMEBand." message in the workspace occurs due to the nodata tile type not matching the band's type. If the band intepretation is Red8, then the nodata tile also needs to be FMERed8Tile. The Red8 band's FMEBandTilePopulator implementation also needs to return the corresponding tile type (in this case, FMERed8Tile). Otherwise, there will be errors about failing to write.

The Python FME Objects API currently distinguishes between omitting a parameter vs supplying a value of None. This distinction is unintended, and we plan to fix this in the future. We'll also look into improving the API's error messages.

View original
Did this help you find an answer to your question?

3 replies

carsonlam
Safer
Forum|alt.badge.img
  • Safer
  • Best Answer
  • October 17, 2017

The "Failed to create FMEBand." message in the workspace occurs due to the nodata tile type not matching the band's type. If the band intepretation is Red8, then the nodata tile also needs to be FMERed8Tile. The Red8 band's FMEBandTilePopulator implementation also needs to return the corresponding tile type (in this case, FMERed8Tile). Otherwise, there will be errors about failing to write.

The Python FME Objects API currently distinguishes between omitting a parameter vs supplying a value of None. This distinction is unintended, and we plan to fix this in the future. We'll also look into improving the API's error messages.


Forum|alt.badge.img
  • Author
  • October 18, 2017

Thank you very much!.. I tried everything but that :-). It makes total sense


Forum|alt.badge.img
  • Author
  • October 18, 2017
fjcharp wrote:

Thank you very much!.. I tried everything but that :-). It makes total sense

Follow-up: the band API works as it should. The nodataValue data type was indeed the culprit. And, to set the record straight, the nodataValue can indeed be omitted from the fmeobjects.FMEBand() parameters, which is the option I chose. My apologies for casting doubt on that.

 

Thank you very much. I am always impressed by the speed with which you guys respond to questions.

 

 

Frederic

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings