Skip to main content
Solved

extract raster cell size


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.

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

9 replies

takashi
Influencer
  • 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
takashi wrote:

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

@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
Influencer
  • March 18, 2016
jamiefinney wrote:

@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
Influencer
  • March 18, 2016
jamiefinney wrote:

@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+44
  • 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
Influencer
  • March 22, 2016
takashi wrote:

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+28
  • Contributor
  • March 22, 2016
mark2atsafe wrote:

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
mark2atsafe wrote:

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.


Reply


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