BookmarkSubscribeRSS Feed
Arbelo
Calcite | Level 5

Dear all,

I work with SAS 9.4.

Now I am trying to apply proc gproject to covert WGS84-coordinates to a particular Lambert-projection.

And keep getting unsatisfactory results.

My test coordinates are:

long=13.84 ; lat=49.77

The correct answer should be

XOK=272304.68; YOK =2212578.11

My code is

data tmp; long=13.84 ; lat=49.77; XOK=272304.68; YOK =2212578.11; run;

proc gproject data=tmp out=tmp1 degrees latlong from="+proj=longlat +datum=WGS84"

to = "+proj=lcc +lat_1=40 +lat_2=60 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"; id ; run;

proc print data=tmp1; run;

XYlonglatXOKYOK
316986.132908828.3913.8449.77272304.682212578.11

which is obviously wrong

Then I tried it in R:

require(rgdal)

require(spatstat)

xy <- c(13.84, 49.77)

sp1 <- SpatialPoints(coord=matrix(xy, ncol=2))

proj4string(sp1) <- CRS("+proj=longlat +datum=WGS84")

spTransform(sp1, CRS=CRS("+proj=lcc +lat_1=40 +lat_2=60 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"))

which gives the correct values:

SpatialPoints:

  coords.x1   coords.x2

[1,] 272304.7  2212578

Does Sas use some kind of a deviant formula for Lambert transformations?

Thanks in advance

1 REPLY 1
GraphGuy
Meteorite | Level 14

It appears there was a bug in version 9.4, and it appears that bug is fixed in the 9.4 maintenance 4 (9.4m4) release.

Here's the output when I run your program at 9.4m4 ...

 

gproject.png

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 1022 views
  • 0 likes
  • 2 in conversation