BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PGStats
Opal | Level 21

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

PG
1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

PG

View solution in original post

9 REPLIES 9
ballardw
Super User

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.

PGStats
Opal | Level 21

Thanks

This is a simplified example. I tried with almost 3000 coordinates and got all UTM coordinates between 0.5 and 1.5... Some of these coordinates are kilometers apart. All have distinct IDs however.

PG

PS. I'm using SAS 9.4

PG
ballardw
Super User

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?!

Darrell_sas
SAS Employee

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.

PGStats
Opal | Level 21

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

PG
CandidedeVoltaire
Calcite | Level 5

Hi, I have a problem somewhat similar...  here is a output test ; coordoninate are lat long from Canada territory.

 
 data have ;
 
  id = "CA-1001" ;
  long = -52.7 ;
  lat  =  47.5 ;
 
 run ;
  
  proc gproject latlon degrees eastlong
  project=proj4 to="EPSG:3347" 
  data=have out=want;
  id id ;
 
 run ;
 
 proc print data=want noobs ;
 
 run ;
 
To my understanding I am using the correct parameters... the results are at the bottom... but the x and y result should be in a 0.45 for X and - 0.08 for Y... not 1026136... ?
 
I have been trying for the last sevral hours to do the right conversion for a map project... If someone can help I would appeciate... Best regards.  Guy
 
X Y id long lat
10261036.29 2376434.81 CA-1001 -52.7

47.5 

ScottJackson
SAS Employee

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

CandidedeVoltaire
Calcite | Level 5

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

CandidedeVoltaire
Calcite | Level 5

Best Regards 😉

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
  • 9 replies
  • 7466 views
  • 3 likes
  • 5 in conversation