Solved

Vector to Raster conversion


Badge +1

Hi,

I have a point Shapefile that I would like to recreate in raster, specifically, ESRI Ascii Grid format.

However I am having issues in that when I use the 'NumericRasterizer', some of the resultant cells in the raster are up to 0.25m away from the original location of the points. Is there any way that I can set the rasterizer (or use a different transformer) to force the resultant cells to be overlaid exactly on the original points (ie: points will lay in the centre of the cell)?

Thanks

icon

Best answer by takashi 24 January 2018, 17:18

View original

11 replies

Userlevel 2
Badge +16

Have you looked at the MapnikRasterizer?

I find that one easy to use.

Badge +1

Have you looked at the MapnikRasterizer?

I find that one easy to use.

Thanks @erik_jan

 

 

I tried the MapnikRasterizer but I am getting the following error:

 

 

REJECTING BELOW FEATURE: Polygon feature must have at least 4 coordinates...rejecting

 

 

I am importing a point shapefile not a polygon file. Is there a way to set it so that it knows I am importing point data.

 

Userlevel 2
Badge +16
Thanks @erik_jan

 

 

I tried the MapnikRasterizer but I am getting the following error:

 

 

REJECTING BELOW FEATURE: Polygon feature must have at least 4 coordinates...rejecting

 

 

I am importing a point shapefile not a polygon file. Is there a way to set it so that it knows I am importing point data.

 

Per imported layer in the MapnikRasterizer you can set the type of features (geometry) and the style options.

 

Have a look at this document: MapnikRasterizer

 

 

Userlevel 4

Can you show us how you've configured the NumericRasterizer?

Badge +1

Can you show us how you've configured the NumericRasterizer?

Hi @david_r

 

 

These are the settings I used!

 

Userlevel 4
Hi @david_r

 

 

These are the settings I used!

 

This is what the transformer is doing, based on your configuration:

 

- Calculate the extent (bounding box) of all your points

 

- Divide the totalt extent into a grid of 0.5 x 0.5 meter large cells

 

- If a point is inside a cell, the cell gets the value from the point

 

So unless your points are all perfectly lined up in accordance with the grid, you'll often get these effects.

 

One way to mitigate this problem could be to set a user-defined ground extent in the NumericRasterizer and do a slight offset compared to your point extents, e.g. half a cell off (-0.25).
Userlevel 2
Badge +17

Hi @aquamarine, I think the NumericRasterizer with your setting creates desired raster if the original points form a grid with spacing 0.5m x 0.5m. How did you confirm that the center of cells in the resulting raster have been moved 0.25m from the original points?

Userlevel 2
Badge +17

Hi @aquamarine, I think the NumericRasterizer with your setting creates desired raster if the original points form a grid with spacing 0.5m x 0.5m. How did you confirm that the center of cells in the resulting raster have been moved 0.25m from the original points?

I checked it with this workspace. numericrasterizer-experiment.fmw (FME 2017.1.2.1)

 

Result. Looks the center of cells in the resulting raster match the original points (red).

Userlevel 4

A possible source of the issue could be that the raster cell size isn't exactly the same as the point spacing. Here's what it looks like if we use Takashi's example and set a raster cell size of 0.55 while retaining a point spacing of 0.5:

Notice how the points "drift" compared to the raster cells, eventually crossing into the neighboring cell.

Userlevel 2
Badge +17

A possible source of the issue could be that the raster cell size isn't exactly the same as the point spacing. Here's what it looks like if we use Takashi's example and set a raster cell size of 0.55 while retaining a point spacing of 0.5:

Notice how the points "drift" compared to the raster cells, eventually crossing into the neighboring cell.

Yes, it's a possible situation. Also if the original points didn't form a grid with equi-spacing, naturally cell centers won't match the original points.

 

Another thought. Once set the cell origin to (0, 0) and then transform the raster into grid points with the RasterCellCorecer, the resulting points match left-bottom corners of the cells. It seems that FME reads an Esri ASCII Grid raster with cell origin (0, 0), so I think this is also a possible situation.

 

Anyway, let's wait for @aquamarine's response.

 

Badge +1

Hi @aquamarine, I think the NumericRasterizer with your setting creates desired raster if the original points form a grid with spacing 0.5m x 0.5m. How did you confirm that the center of cells in the resulting raster have been moved 0.25m from the original points?

Thanks @takashi

 

I realize now that the issue was that my original point shapefile was not evenly gridded at 0.5m intervals and that's why I wasn't getting the NumericRasterizer to work. I will need to recreate the point shapefile with 0.5m intervals.

Reply