BookmarkSubscribeRSS Feed
CamRutherford
Fluorite | Level 6

Hello,

 

I have a list of Long/Lat codes which I'd like to plot on a map.

 

The codes are not in the US and are worldwide, including europe and the middle east.

 

Please can anyone help me?

 

Thanks,

Cam

7 REPLIES 7
rogerjdeangelis
Barite | Level 11
SAS/R: Google Annotated map of New York City

If you have IML interface to R you can cut and paste the code
below. Also you could use Python.

see for high res map
https://www.dropbox.com/s/ax7i5mvr5ctjgcm/nyc.png?dl=0


HAVE
====

  Up to 40 obs WORK.HAVE total obs=2

  Obs    LATITUDE    LONGITUDE    LOGPRICE

   1      40.7033      40.7082       120
   2     -74.0192     -74.0054        56

 Google bounding box for NYC -> ggmap::get_map("New York City", zoom = 14);
 https://www.mapdevelopers.com/geocode_bounding_box.php


WANT
====

  High resolution map of NYC with circles at HAVE data


FULL SOLUTION

*                _                  _       _
 _ __ ___   __ _| | _____        __| | __ _| |_ __ _
| '_ ` _ \ / _` | |/ / _ \_____ / _` |/ _` | __/ _` |
| | | | | | (_| |   <  __/_____| (_| | (_| | || (_| |
|_| |_| |_|\__,_|_|\_\___|      \__,_|\__,_|\__\__,_|

;

options validvarname=upcase;
libname sd1 "d:/sd1";

data sd1.have;

 input
    latitude
    longitude
    logprice
 ;

cards4;
40.7032815 40.7082398 120
 -74.0192166 -74.0054436 56
;;;;
run;quit;

*____
|  _ \
| |_) |
|  _ <
|_| \_\

;

%utl_submit_r64('
source("c:/Program Files/R/R-3.3.2/etc/Rprofile.site",echo=T);
library(ggmap);
library(haven);
mapnyc=read_sas("d:/sd1/have.sas7bdat");
png("d:/png/nyc.png");
nyc_base <- ggmap::get_map("New York City", zoom = 14);
ggmap(nyc_base) + geom_point(data=mapnyc,
  aes(x=LONGITUDE, y=LATITUDE), color="red", size=20, alpha=0.5);
');


%macro utl_submit_R64(pgmx)/des="Semi colon separated set of R commands";
  * write the program to a temporary file;
  filename r_pgm temp lrecl=32766 recfm=v;
  data _null_;
    file r_pgm;
    pgm=&pgmx;
    put pgm;
    putlog pgm;
  run;
  %let __loc=%sysfunc(pathname(r_pgm));
  * pipe file through R;
  filename rut pipe "c:\Progra~1\R\R-3.3.2\bin\x64\R.exe --vanilla --quiet --no-save < &__loc";
  data _null_;
    file print;
    infile rut;
    input;
    put _infile_;
    putlog _infile_;
  run;
  filename rut clear;
  filename r_pgm clear;
%mend utl_submit_r64;



NYC

rogerjdeangelis
Barite | Level 11
It looks like SAS only allows one layer. If you go to the 'dropbox' link you will see the 'red dots'
Reeza
Super User

Maybe this can get you started. In general, robslink page will have an example close to what you want. 

 

http://robslink.com/SAS/democd57/jordan_lake_paddling_info.htm

 

CamRutherford
Fluorite | Level 6

Okay, thank you for the below.

 

For example, If I wanted to have the long/lat points pinned on a Great Britain Map - how could I do that? Creating a heat map.

 

Thanks,

Cam

rogerjdeangelis
Barite | Level 11

If you look up the bounding box for Great Britain and create a SAS dataset with the 'pins' (lat log').  You can create pins on the google map. I suggest you look at the R documentation for ggmap.

 

You can also do this with SAS 'proc gmap'.

CamRutherford
Fluorite | Level 6
Thank you - do you know how I can reference UK maps in SAS? All the documentation I see is for US.
ballardw
Super User

@CamRutherford wrote:
Thank you - do you know how I can reference UK maps in SAS? All the documentation I see is for US.

Anything you see that references MAPS.US (or MAPS.USCOUNTY) you can likely replace with MAPS.UK but you need to check the different Id variables. Maps.UK2 has some regional descriptions for the ID in UK, a 'feature table' dataset.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 1734 views
  • 0 likes
  • 4 in conversation