Hi,
This my first attempt to transform latitudes and longitudes into UTM (Zone 18) coordinates using SAS. PROC GPROJECT PROJECT=proj4 seems to be what I need but I can’t get the desired result :
data have;
id=1; lat=45.5; long=73.5;
run;
proc gproject latlon degrees westlong
project=proj4 to="EPSG:32618" /* WGS 84 / UTM zone 18N */
data=have out=want;
id id;
run;
proc print data=want noobs; run;
X Y id lat long
1.28282 0.79412 1 45.5 73.5
X and Y are clearly not what I expect. Please help!
PG
Thank you Darrell, I got it now. It turns out that options EASTLONG, WESTLONG and DEGREES are ignored for METHOD=PROJ4. Longitudes must be within the specified limits for the UTM zone (and negative), otherwise GPROJECT gives garbage without any warning. The correct projection will be given by:
data have;
id=1; lat=45.5; long=-73.5;
run;
proc gproject latlon
project=proj4 to="EPSG:32618" /* WGS 84 / UTM zone 18N */
data=have out=want;
id id;
run;
proc print data=want noobs; run;
X Y id lat long
617189.99 5039590.76 1 45.5 -73.5
PG
I would try adding a few other points.
In 9.3 with any of the available projections except NONE a single points yields output of 0,0. So it may be an effect of not having something else to generate.
It has been awhile since I tried projecting any data from lat/long but my results back then seemed to yield a x in the -1 to 1 and y in -1 to 2 range. I suspect those results were just SAS drawing coordinate for GMap. Maybe something similar is happening here?!
What numbers are you expecting?
The doc says: The DEGREES and EASTLONG options are enabled with the PROJ4 projection method.
I think that means you CANNOT turn on WESTLONG. I think the doc isn't very clear on this.
Also, the PROJ4 doc says the LONG/LAT must be: -78.0000, 0.0000, -72.0000, 84.0000
(WGS 84 / UTM zone 18N: EPSG Projection -- Spatial Reference)
So, you need to change your value to EASTLONG.
Thank you Darrell, I got it now. It turns out that options EASTLONG, WESTLONG and DEGREES are ignored for METHOD=PROJ4. Longitudes must be within the specified limits for the UTM zone (and negative), otherwise GPROJECT gives garbage without any warning. The correct projection will be given by:
data have;
id=1; lat=45.5; long=-73.5;
run;
proc gproject latlon
project=proj4 to="EPSG:32618" /* WGS 84 / UTM zone 18N */
data=have out=want;
id id;
run;
proc print data=want noobs; run;
X Y id lat long
617189.99 5039590.76 1 45.5 -73.5
PG
Hi, I have a problem somewhat similar... here is a output test ; coordoninate are lat long from Canada territory.
X | Y | id | long | lat |
---|---|---|---|---|
10261036.29 | 2376434.81 | CA-1001 | -52.7 |
47.5 |
Guy,
What is the projection that you are trying to convert into? The values that you are getting from the proc for that EPSG value appear to be correct. I looked up the range of values for the UTM represented by EPSG:3347, and those returned values are in the expected range.
For reference, here is the definition of EPSG 3347 from spatialreference.org that I used:
http://spatialreference.org/ref/epsg/nad83-statistics-canada-lambert/
Thanks,
Scott
I found the ligth at the end of the tunnel... The problem was not a conversion problem.... I was in the Mapsgfk.canada and Mapsgfk.canada_attr map files. The X and Y variables used in those maps were generated by the map provider... I could not find any way of converting external points in Latitude and longitude to those internal coordinates. The solution was so simple, I imported the Canadian SHP map file from open data Stat Can with MAPIMPORT... The coordinates X Y in the map is in Latitude and longitude... so I repeated the program and all is good. Hoping my experience can be useful for someone in the future.
Best retards Scott
Best Regards 😉
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.