Skip to main content

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

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


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.


@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 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 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.


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.


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.


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.


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