Satellite Map:
Click here to see the SAS code.
Click here to see the example.
Geologic Map:
Click here to see the SAS code.
Click here to see the example.
---------------------------------------------------------------
Note: This could probably be re-done, using the techniques similar to
democd55/peru_openstreetmaps.htm
This example shows how to take an image (such as jpg, or gif) of a certain
geographical region, and overlay/integrate that with a SAS/Graph gmap,
so that you can see it in the right location, and also annotate markers, etc
onto the map. This could include satellite images, images scanned in from
a book, etc.
You must first start out with an image that corresponds to a rectangular area.
If you are zoomed into a small enough area, most maps are pretty much rectangular.
It also helps if the image has lat/long lines on it, so you know exactly what
area you have.
Then take the image into an image editor and crop it so that *only* the
rectangular area bounded by the desired lat/long grid is in the image
(have no pixels, or borders, etc outside that rectangular area!)
And, since I'm lazy (errr... otherwise known as efficient!) I used the
lat/long coordinates of the bottom/left and top/right coordinates as
part of the filename, so that I could then parse them out of the name
(programmatically) rather than having to keep track of the coordinates
for each image. For example, my satellite image with bottom-left corner
at 14.0-south 76.5-west and top-right corner at 13.5-south 76.0-west ...
peru_images/cropped/sat140s765w-135s760w.jpg
Or, to look at all the images in the folder:
peru_images/
--------------------------------------------------------------------
Here's where/how I got the images for these 2 examples (goelogical & satellite images):
-----
I got the geological maps from here:
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/indice.htm
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/28-k.jpg
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/28-l.jpg
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/29-k.jpg
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/29-l.jpg
http://www.ingemmet.gob.pe/publicaciones/serie_a/mapas/30-l.jpg
etc...
-----
Got the satellite images from Google Earth
Zoomed into the desired area.
View->Grid
File->Save->Save Image
-----
In both cases, once I got the jpg image, I cropped it to just the
lat/long grid I wanted, and saved that version in the "cropped" folder.
(Also, for a few of them, I used Photoshop to "straighten" the image.)
-----
Renamed the files, so the filename shows the lat/long extents:
Geological Maps:
mv 28-k.jpg geo140s765w-135s760w.jpg
mv 28-l.jpg geo140s760w-135s755w.jpg
mv 29-k.jpg geo145s765w-140s760w.jpg
mv 29-l.jpg geo145s760w-140s755w.jpg
mv 30-l.jpg geo150s760w-145s755w.jpg
etc...
Satellite Maps:
mv 28-k_google.jpg sat140s765w-135s760w.jpg
mv 28-l_google.jpg sat140s760w-135s755w.jpg
mv 29-k_google.jpg sat145s765w-140s760w.jpg
mv 29-l_google.jpg sat145s760w-140s755w.jpg
mv 30-l_google.jpg sat150s760w-145s755w.jpg
etc...
-------------------------------------------------------
To place the images on the SAS/Graph gmap, I use the annotate function='image',
and imagepath='{path/filename.jpg}'. I use xsys='2' and ysys='2' so that the
image is in the same coordinate system as the map, and I convert the lat/long
degrees values to radians (since the map coordinates are in radians).
I do a function='move' to the bottom/left corner of where I want to annotate
the image, and then use function='image' specifying the top/right corner.
I use when='b' so the image will be drawn before/behind the map.
In the mapping world, this is sometimes called "two corner registration,
and it assumes that the map projection you're going to use produces
pretty much rectangular areas - if you're zoomed into a small enough area,
this shouldn't be a problem, but on larger areas you might have to lean
towards projections such as 'cylindri'.
I combine the annotate data set with the map data set, and use "proc gproject"
to project them at the same time (this guaranteed everything stays lined up
correctly), and then after the gproject I separate the data sets.
Then just use "proc gmap" to draw the map, and use gmap's anno= option to
specify the annotate data set.
I could use when='b' (before/behind) for the annotated image, and a clear/empty
pattern for my map areas, so that you can see the image through them (do this
using the v=empty on the pattern statement)...
But instead I'm getting a little fancy, and doing a solid colored map pattern,
and then annotating the layers for the map, the city markers, and then
the lat/long grid.
For the map quadrants, I set up the html= variable to do a drilldwon to the
un-cropped map for that area, and the dots do a google search on the city name.
Oh - you'll also want to use v9.2 and dev=png ... v9.2 has several enhancements
so the annotated images look better (not dithered), and v9.2 png device
supports >256 colors, which you will likely need!
Back to Samples Index