BookmarkSubscribeRSS Feed
andersonh
Calcite | Level 5

I've been working with proc sgmap to generate some plots that are meant to be included in some printed material, and I'm trying to get rid of the white border around the edge of the plots.  The images are being handed off to someone working in our communications department who's using a separate piece of software to format and typeset the printed materials, and I need to provide them with the images at a pre-defined resolution and DPI.

 

I can get the DPI of the overall image working just fine, and can turn off the titles/legends/borders without issue, but I've gotten completely stuck trying to make the whitespace go away.  I got as far as experimenting with proc template and defining new styles, but I couldn't figure out how to make any of the pieces take effect.  Currently I'm falling back on batch processing the images locally to trim the whitespace, but it would be much easier if I could just generate them without the whitespace in the first place, so I don't have to do some extra work to find how much is getting trimmed off (especially if I need to change the DPI, and the number of pixels being trimmed will change).

 

Unfortunately I can't share my data, but here's some code that illustrates the issue.  It just draws a black box around Texas:

 

data work.ChoromapData;
	infile datalines delimiter=" ";
	input x y id $;
	datalines;
-94 25 Texas
-94 37 Texas
-106 37 Texas
-106 25 Texas
-94 25 Texas
;
run;

ods listing gpath="/home/my_user/" device=png; ods graphics on / height=500 width=500 noborder; proc sgmap mapdata=work.ChoromapData; openstreetmap; choromap; run;

 

 

 

 

The images I get out look like this.  I've colored the whitespace around the edge a bright red, so it's easier to see against the forum background, but it's white in my program's output.  Normally this would be the region between the map and the thin border that surrounds the whole image (but I've turned the border off with the ods graphics statement).

forum demo.png

 

What I want is this (note the lack of whitespace around the edges):

trimmed.png

 

I've been trying to get this sorted out for a few days now but have made zero progress.  Anyone have any ideas/solutions that maybe I've just not come across yet?

 

Technical details: I'm working in Enterprise Guide 8.3, and SAS version 9.4M7 (full version number: 9.04.01M7P080520).

3 REPLIES 3
andersonh
Calcite | Level 5

Updates: I still haven't figured this out, and the amount of padding seems to change depending on the combination of DPI and height/width ods graphics options.  I also can't determine what template proc sgmap is using (ods trace doesn't have any "Template:" entry with it), and none of the existing templates seem to have anything to do with sgmap, so I have no clue where to even start if I want to dive back into proc template.

 

Does anyone have anything that might help me out here?  I keep getting frustrated with this, and I feel like I keep banging my head against this problem every few days and never making any progress.

GraphGuy
Meteorite | Level 14

Just so everyone's clear on what this example is doing ... the user's "map" is the rectangular black polygon (they specified 5 lat/long coordinates in their map dataset), and then Proc Sgmap automatically determines which Openstreetmap tiles to put behind it. I'm not 100% certain whether Sgmap has to use whole tiles, or if it 'trims' the tiles. In this case the black rectangle is the user's map polygon, not the border of the page. None of these details shed any light on the user's actual question, but thought I'd explain, just in case you were curious or confused.

 

Per the user's question about having the Sgmap go all the way to the edge of the available space, so that there's absolutely no "white space" around the edge ... I don't know of any way to do that. I'm not saying it's "impossible" but I don't know of a way.

 

JeffMeyers
Barite | Level 11
I looked through the options and didn't see any padding options. It looks like it's being put there with padding or offsets on a non-visible x/y axis. Do you know if there's any options you can put in a style template to control how much padding there is? Otherwise whoever designed the proc probably would have to add the option I would imagine? I think it I read it was made by a 3rd party. I couldn't find anyway to replicate with just GTL.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 815 views
  • 0 likes
  • 3 in conversation