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
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;
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
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
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 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.
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!
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.
Ready to level-up your skills? Choose your own adventure.