Skip to main content

I'm buffering a points shapefile, then using the resulting square polygons to clip a raster (vrt OS backdrop). The clipped rasters are then passed to a PDF PageFormatter to produce location maps for each point. My problem is the raster outputs once written to PDF seem to move - placed in relation to the location of the point. how can I force the rasters to be drawn in the same place on the page everytime?

Hello @cbrown​ 

Are you able to share an example of the behaviour you're describing? If you can share the workspace, that would also be helpful.

The PDFPageFormatter should set the pdf_frame_rectangle format attribute, which controls the position of a given frame on the PDF page. In contrast, the pdf_world_rectangle controls the extents of the features (the point and raster background in your case) displayed in a PDF frame.


Hi @debbiatsafe​ 

thanks for getting back to me. I've set the position in the PDFPageFormatter. Does this automatically set the pdf_frame_rectangle format attribute when transferred to the PDF Writer? Or do I need to enable this (and maybe other attributes)? I've attached an example where you can see the map content shifts from page to page.

imageimage 

 


Hi @debbiatsafe​ 

thanks for getting back to me. I've set the position in the PDFPageFormatter. Does this automatically set the pdf_frame_rectangle format attribute when transferred to the PDF Writer? Or do I need to enable this (and maybe other attributes)? I've attached an example where you can see the map content shifts from page to page.

imageimage 

 

Using the PDFPageFormatter should set the pdf_frame_rectangle format on output features. I suspect the behaviour you're seeing is caused by the fact you are using one PDFPageFormatter and then manually changing pdf_page_number afterwards.

The cumulative bounding box/extents of all features for each frame/box defined in the PDFPageFormatter is used to determine the pdf_world_rectangle. Since you have multiple locations for a single frame, the pdf_world_rectangle extents encompasses all features and causes the shifting behaviour.

I would recommend using a BoundsExtractor on the background map features and using those values to set pdf_world_rectangle in the format <lowerLeftX> <lowerLeftY> <upperRightX> <upperRightY>. Also set a unique frame name for each map frame for each page--the name can be any format.

I'll note also it may be easier to use one frame/box per map instead of defining one for the point features and one for the background as your screenshot shows. This ensures each frame has consistent values.

I have attached an example demonstrating this approach and I hope it helps.


Using the PDFPageFormatter should set the pdf_frame_rectangle format on output features. I suspect the behaviour you're seeing is caused by the fact you are using one PDFPageFormatter and then manually changing pdf_page_number afterwards.

The cumulative bounding box/extents of all features for each frame/box defined in the PDFPageFormatter is used to determine the pdf_world_rectangle. Since you have multiple locations for a single frame, the pdf_world_rectangle extents encompasses all features and causes the shifting behaviour.

I would recommend using a BoundsExtractor on the background map features and using those values to set pdf_world_rectangle in the format <lowerLeftX> <lowerLeftY> <upperRightX> <upperRightY>. Also set a unique frame name for each map frame for each page--the name can be any format.

I'll note also it may be easier to use one frame/box per map instead of defining one for the point features and one for the background as your screenshot shows. This ensures each frame has consistent values.

I have attached an example demonstrating this approach and I hope it helps.

Alternatively, get the bounds using a BoundsExtractor and offset everything to -1*xmin, -1*ymin, this has the effect of moving all objects so that their lower left bounding box corner lands at 0,0


Reply