Watch this Ask the Expert session to learn how to use the SGMAP procedure to create effective displays of your geographical data. We’ll cover a range of topics, including basic map creation, overlaying plots, attribute control and data categorization.
You will learn:
The questions from the Q&A segment held at the end of the webinar are listed below and the slides from the webinar are attached.
Could you further explain what OPENSTREETMAP is?
Yes, we are talking about background maps or base maps. If you’ve ever used Google Maps, that is an example of a background or base map. The way that technology works is that a map server represents the world as little tiled images. Based on what your zoom level is, or what you’re trying to see, it goes out and collects tiles, brings these tiles back and lays them out adjacent to one another so that you see the entire map or the area you’re try to see. The OPENSTREETMAP server basically works the same way. The OPENSTREETMAP server that we use is SAS-maintained server. The ESRI map server is maintained by ESRI. So, any enhancements to OPENSTREETMAP output, when you use that statement, is coming from enhancements that we do on our tile server from the servers we maintain.
Can SGMAP create animated maps like GMAP?
Yes, you can. The animation is not controlled from the procedure, it’s actually controlled by the outside, from ODS. And so, the same approach that you use in GMAP for creating that animation should also work for SGMAP as well.
What is the main difference between SGMAP and GMAP? I am new to SAS mapping and I am deciding which one to learn.
The technology behind them is very different. GMAP is using, what we call, “device-based” graphics. This is catalog-based graphics and is an older technology. SGMAP is using “template-based” graphics, which is a newer technology. There’s a lot more work right now going into the technology used by SGMAP. If I were learning the two, I would probably lean toward SGMAP for that reason. For example, let’s take background maps. GMAP does not support background maps (with one exception). There was a device called "javaimg" that would let you use OPENSTREETMAP output. But, the GRSEG technology in GMAP makes it difficult to support that functionality whereas you could easily do that kind of thing now for SGMAP. And so, as you can see with background maps, you can create a lot of really nice, enhanced graphics. Also. GMAP doesn’t support plot overlays. You can do some amazing things with annotation. You can do all kinds of drawings, but by using plot technology on top of our maps, it behaves like a plot and gives you better behaviors without having to work so hard at it. I would move forward into the SGMAP area for creating your enhanced maps.
Does SGMAP support mouse-over tool tips?
Yes, that’s what we were showing earlier in one of the slides. The key is on the ODS Graphics statement. You use the IMAGEMAP option to turn on that tool tip information and then you’ll actually get it by default in your HTML output. If you mouse over data features, you’ll get a tip for whatever pertains to that plot or to that map. You can also control the tip content like we were showing earlier with the TIP and TIPLABEL options. There is also a TIPFORMAT option that was not shown.
Can we use the color range option on other graphs besides maps?
Absolutely yes, you can. For example, let’s say you had a bubble plot and had another numeric variable you were putting on your bubble to control the color. You could assign that variable to the COLORRESPONSE option, and you can map that variable to a range attribute map. Or, if you wanted to discretely color bubbles, use the GROUP option and a discrete attribute map. All of these attribute maps apply to the plots. And that same attribute map technology also applies to SGPLOT and SGPANEL, so that’s something we just brought over into the SGMAP area.
If we can access URL by firewall, can we download the map first and use it? What is the command for downloaded map?
If you’re talking about the background maps, unfortunately not. You can’t download it, that content is huge. You would also have to have your own server set up to serve the tile information. Also, the OPENSTREETMAP statement is designed to reference SAS's servers.
Since you have SGMAP in ODS Graphics now, are there any features left in the traditional SAS/Graph that you can't do in ODS Graphics?
Yes, there are things here and there, and there are certain things that we will bring forward. We try to evaluate and decide what makes sense, and what people are using the most. To give an example, I told you SGMAP does not currently support annotation, but we also recognize that annotation is something that’s very useful and that’s something we are going to add in a future release. So, with things like that, we still need to bring those kind of things forward. But, we will continue to evaluate what things we should bring over in the ODS Graphics area.
Can projections be adjusted on the background map layers?
Yes. If you’re using the background map, you should not use projected data, The data should be unprojected. A Web Mercator or modified Mercator projection is used to take all of your unprojected map and plot information and put it on the background map. There are ways of adjusting your projected data to work on a background map. In fact, there’s an option called PLOTCS and MAPCS to where you can actually do some modification to the projection without going through PROC GPROJECT. I think there’s more documentation on those options, but there are ways to adjust your projections. I do recommend if you’re using a background map, use unprojected data.
Where is the best place to obtain shape files to leverage power of SGMAP? For instance, to plot detailed maps for retail store or hospital locations.
That really depends. For example, if the hospital puts out a floor plan of their hospital and they put it out as a shapefile, you can import it and you can use it. It’s information that is available to you. There’s not like what I call a “central source,” It kind of depends what you’re looking for. Take the hurricane example, NOAA put out a shapefile for the cone of uncertainty. That was available, so we could use that to draw that cone. So, it just really depends on what you’re trying to map out and whether that information is available publicly as shapefiles.
Is it possible to use other format than shapefile? Especially, is geopackage (GPKG) possible?
GeoPackages are not currently supported.
Can you use SGMAP to plot millions of addresses or are there limitations?
SGMAP is not really plotting addresses, we’re just plotting the latitude and longitude, so it depends on what is meant by “plotting addresses.” If you’re talking about taking a scatterplot on top of the map and drawing points on certain addresses, it’s capable of drawing those. There’s a certain point where it just kind of turns into a mess. If you think about it, your default output size is 640 by 480 in terms of pixel size. If you draw millions and millions of points, it’s just going to turn into a blob. There’s the theoretical, “I could draw this many points,” and then there’s a practical, “How many can I draw and actually be able to tell what I’m drawing?”
Will the map created by SAS VA replace the ones by PROC SGMAP or other PROC?
No, those are really in two different areas. For example, if I’m inside of VA and I’m using map output, there’s a lot of interactive functionality that’s used inside of VA with mapping. But, for people who may be creating static reports, they might be one to use SGMAP which is hopefully easy to program, and something you can run in batch very easily. So, I think it’s different audience depending on what you’re trying to accomplish. I think they are complementary.
Is there a way to display state names and the stats?
As far as state names go, if you use a background map, I think we had an example of this earlier where the state names were actually there on the state. They showed thorough the slightly transparent CHOROMAP. You can use that approach, or you can actually put information in the polygon. There are ways of computing centroids for the polygon information and, once you’ve computed the centroids, you can use a text plot to actually put all the state names on the map. As far as statistics, there’s no statistics being computed here. We’re just drawing the values as we’ve been given. So, if there’s any additional statistics you want to show, I would either show those as tip information on the map when you mouse over or maybe use a text plot to put some information maybe off to the side of the map.
Are the open street maps (mapsgfk.us_states) available to anyone using SAS without loading in a specific url like for the ESRI maps?
First of all, the MAPSGFK data sets do not involve Open Street Maps. The MAPSGFK map data is included with anyone who has a SAS/Graph license.
ESRI assumes an internet connection is viable ... is that obvious? SAME for OPENSTREETMAP
You are correct -- you must have an internet connection to the map server.
Quantile ... is the default 6 groups?
No, the default is computed from the data.
Creating Great Maps in ODS Graphics using PROC SGMAP
SAS PROC SGMAP: Examples and Code Snippets
SAS Programmer Week (Free + Virtual)
Want more tips? Be sure to subscribe to the Ask the Expert board to receive follow up Q&A, slides and recordings from other SAS Ask the Expert webinars.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Ready to level-up your skills? Choose your own adventure.
Your Home for Learning SAS
SAS Academic Software
SAS Learning Report Newsletter
SAS Tech Report Newsletter