Skip to main content
Solved

extract raster cell size

  • March 18, 2016
  • 9 replies
  • 117 views

Forum|alt.badge.img

i want to off set a raster by half cell size in XY so points created from it will be at the pixel center rather than the lower left hand corner. How can i expose these values so they don't have to be manually typed in?

the import format is ASCII grid so the information is right there in the header

ncols 200

 

nrows 200

 

xllcorner 220000

 

yllcorner 70000

 

cellsize 50

Best answer by takashi

Hi @jamiefinney, the RasterPropertyExtractor might help you. Check the _spacing_x, _spacing_y attributes which will be extracted by the transformer.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

9 replies

takashi
Celebrity
  • Best Answer
  • March 18, 2016

Hi @jamiefinney, the RasterPropertyExtractor might help you. Check the _spacing_x, _spacing_y attributes which will be extracted by the transformer.


Forum|alt.badge.img
  • Author
  • March 18, 2016

Hi @jamiefinney, the RasterPropertyExtractor might help you. Check the _spacing_x, _spacing_y attributes which will be extracted by the transformer.

@takashi Thank you for that i knew there had to be that function in there somewhere.


Forum|alt.badge.img
  • Author
  • March 18, 2016

@takashi how would i transfer these values into an offsetter transformer.

i getting errors when i try to add this into my model

either that the offset variable isn't a float value - @Value(_spacing_x)/2

or that the raster is being routed through the model and causing an error as a raster can't be exported as a mapinfo tab file.


takashi
Celebrity
  • March 18, 2016

@takashi how would i transfer these values into an offsetter transformer.

i getting errors when i try to add this into my model

either that the offset variable isn't a float value - @Value(_spacing_x)/2

or that the raster is being routed through the model and causing an error as a raster can't be exported as a mapinfo tab file.

@jamiefinney, insert the RasterPropertyExtrastor between the reader and RasterCellCoercer, and set "Yes" to the "Preserve Attributes" parameter of the RasterCellCoercer.


takashi
Celebrity
  • March 18, 2016

@takashi how would i transfer these values into an offsetter transformer.

i getting errors when i try to add this into my model

either that the offset variable isn't a float value - @Value(_spacing_x)/2

or that the raster is being routed through the model and causing an error as a raster can't be exported as a mapinfo tab file.

You can also offset the raster before coercing.


mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • March 18, 2016

You could use the RasterCellOriginSetter transformer, and set it to 0.5,0.5 - then the cell origin would be the centre of the cell and you wouldn't need the Offsetter.

So, just :

  1. RasterCellOriginSetter
  2. RasterCellCoercer
  3. AttributeCreator
  4. Tiler... etc

I think that would be the most appropriate way, and quicker too.


takashi
Celebrity
  • March 22, 2016

Hi @jamiefinney, the RasterPropertyExtractor might help you. Check the _spacing_x, _spacing_y attributes which will be extracted by the transformer.

Hi @jamiefinney, I answered straightly to your question - i.e. how to extract raster cell size. However, I agree with @Mark2AtSafe. The RasterCellOriginSetter would be the most efficient way, if you need to extract center points for each cell of an ASCII grid raster.


jdh
Contributor
Forum|alt.badge.img+40
  • Contributor
  • March 22, 2016

You could use the RasterCellOriginSetter transformer, and set it to 0.5,0.5 - then the cell origin would be the centre of the cell and you wouldn't need the Offsetter.

So, just :

  1. RasterCellOriginSetter
  2. RasterCellCoercer
  3. AttributeCreator
  4. Tiler... etc

I think that would be the most appropriate way, and quicker too.

This method has the added benefit that it works regardless of the original cell origin, whereas the offsetter method requires the ascii grid to be in the xllcorner instead of xllcenter format.


Forum|alt.badge.img
  • Author
  • March 22, 2016

You could use the RasterCellOriginSetter transformer, and set it to 0.5,0.5 - then the cell origin would be the centre of the cell and you wouldn't need the Offsetter.

So, just :

  1. RasterCellOriginSetter
  2. RasterCellCoercer
  3. AttributeCreator
  4. Tiler... etc

I think that would be the most appropriate way, and quicker too.

@Mark2AtSafe good idea thanks for that - seems like a much more efficient way.