[R-sig-Geo] problems loading spproj library for transform()

Roger Bivand Roger.Bivand at nhh.no
Fri May 26 00:59:34 CEST 2006


On Thu, 25 May 2006 karl.sommer at dpi.vic.gov.au wrote:

> 
> thanks for the prompt reply
> 
> the method spTransform() worked
> 
> I now have an attribute file of class SpatiaPointsDataFrame with EM38
> readings.  I also have a separate shape file of class
> SpatialPolygonsDataFrame which I imported form an ESRI shape file using the
> readOGR() method of rgdal.  I would like to superpose the two files in a
> plot but so far have not been successful in lining them up satisfactorily.
> I am not sure if the misalignement is due to my misguided plotting method
> 
> p1 <- spplot(x, c("var"))  #attribute data
> p2 <- spplot (x2)  # shapefile
> 
> print(p1, split = c(1,1,1,1), more = TRUE)
> print(p2, split = c(1,1,1,1), more = FALSE)

Th spplot() methods use lattice graphics, so I am not confident that you 
can validly overplot. Can you try first with base graphics, possibly using 
xlim= and ylim= to zoom in and locator() to check coordinates? 

Shapefiles do not themselves have projection information, it is in a 
separate *.prj file. If you don't have one, you may need to establish it 
yourself. It is not used for plotting Spatial* objects beyond 
conditionally stretching the y axis aspect when is.projected() is TRUE. If 
the objects have been created by spTransform(), the projection information 
has been set, and can be accessed by proj4string().

Roger

> 
> or due to the fact that the projections of the two files differ.  I am not
> sure how to extract projection information from the shape file.
> 
> any hints would be appreciated
> 
> Karl
> 
> 
> 
> |---------+----------------------------------->
> |         |           Roger.Bivand at nhh.no     |
> |         |           Sent by:                |
> |         |           r-sig-geo-bounces at stat.m|
> |         |           ath.ethz.ch             |
> |         |                                   |
> |         |                                   |
> |         |           25/05/2006 15:41        |
> |         |           Please respond to       |
> |         |           Roger.Bivand            |
> |         |                                   |
> |---------+----------------------------------->
>   >------------------------------------------------------------------------------------------------------------------------------|
>   |                                                                                                                              |
>   |       To:       mdsumner at utas.edu.au                                                                                         |
>   |       cc:       r-sig-geo at stat.math.ethz.ch                                                                                  |
>   |       Subject:  Re: [R-sig-Geo] problems loading spproj library for transform()                                              |
>   >------------------------------------------------------------------------------------------------------------------------------|
> 
> 
> 
> 
> On Thu, 25 May 2006, Michael Sumner wrote:
> 
> > Hello
> >
> > I have the same problem, I've been meaning to explore further before
> > posting, but since spproj is not on CRAN I don't think I've missed
> > something obvious. This seems to be related to rgdal 0.4-4:
> >
> 
> In rgdal, try running example("spTransform-methods") - if it works, use
> spTransform() instead of transform().
> 
> Sorry for the muddle.
> 
> Roger
> 
> > ## using data from ?project example
> >
> > library(rgdal)
> >
> > ## project works OK
> >   data(state)
> >   res <- project(cbind(state.center$x, state.center$y), "+proj=lcc
> > +lat_1=48 +lat_2=33 +lon_0=-100")
> >   res1 <- project(res, "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100",
> > inv=TRUE)
> >
> > ## but transform does not
> >
> > res <- SpatialPoints(res, CRS("+proj=lcc +lat_1=48 +lat_2=33 +lon_0
> =-100"))
> >
> > sessionInfo()
> > #Version 2.3.0 (2006-04-24)
> > #i386-pc-mingw32
> >
> > #attached base packages:
> > #[1] "methods"   "stats"     "graphics"  "grDevices" "utils"
> "datasets"
> > #[7] "base"
> >
> > #other attached packages:
> > #   rgdal   pixmap    abind       sp
> > # "0.4-4"  "0.4-4"  "1.1-0" "0.8-14"
> >
> >
> > transform(res, CRS("+proj=longlat"))
> > #Loading required package: spproj
> > #Error in transform(res, CRS("+proj=longlat")) :
> > #        for using (coordinate) transform on objects deriving from
> > Spatial, library spproj is required
> > #In addition: Warning message:
> > #there is no package called 'spproj' in: library(package, lib.loc =
> > lib.loc, character.only = TRUE, logical = TRUE,
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
> 
> --
> Roger Bivand
> Economic Geography Section, Department of Economics, Norwegian School of
> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
> e-mail: Roger.Bivand at nhh.no
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 
> 
> 
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list