On Sun, Dec 16, 2012 at 12:15 PM, Barry Rowlingson <
b.rowlingson@lancaster.ac.uk> wrote:

> On Sun, Dec 16, 2012 at 5:19 PM, Edzer Pebesma
> <edzer.pebesma@uni-muenster.de> wrote:
> > Hi Barry, that sounds like a great project. As of your (only) example, I
> > already see, after loading package raster:
> >
> >> showMethods(proj4string)
> > Function: proj4string (package sp)
> > obj="Raster"
> > obj="Spatial"
> >
> > Loading Tcl/Tk interface ... done
> >> getMethod(proj4string, "Raster")
> > Method Definition:
> >
> > function (obj)
> > {
> >     projection(obj)
> > }
> > <environment: namespace:raster>
> >
> > Signatures:
> >         obj
> > target  "Raster"
> > defined "Raster"
> >
> > or do you suggest that sp should adopt the use of projection() as well?
> >
> > I'm looking forward to many reactions too, but will draw my conclusions
> > if there aren't any.
>
>  I'm not sure I like 'projection' at all. Technically these are
> spatial coordinate reference systems. I think I would prefer to assign
> a coordinate reference system with the CRS<- function:
>
>
I agree that CRS is the ideal function name. It is not a generic so I could
not use it in raster. I considered "crs" but thought that could be too
confusing; so I used projection which at least seemed better than
proj4string (proj4 refers to the format (unit), not to the type of variable
and it is not a string (in sp needs to be an object of class CRS)). More
recently I added proj4string anyway because it is what many expected having
seen an example with sp.

But I would not do this:

CRS(foo) = proj4("+init=epsg:27700")
>

Instead I would do this:

CRS(foo) <- "+init=epsg:27700"

Because it is, in my opinion, an unnecessary step for the user to create an
object of class CRS from a proj4 _string_  the function can do that:

But if you wished ot explicitly create a CRS object

crsobj <- CRS("+init=epsg:27700")

And then this should work too:

CRS(foo) <- crsobj


>
> that would allow the possible use of other reference system specs, e.g.
>
> CRS(foo) = wktProj('GEOGCS["WGS 84".... etc]')


That is a transformation, so I would think:

 foo = spTransform('GEOGCS["WGS 84".... etc]')

and foo could be either of class 'character' (a.k.a. a proj4-string) or an
object of class CRS


but of course things like spTransform would have to understand how to
> convert from things that aren't specified by a proj4 object, so they'd
> probably have to error.
>
> The proj4 and wktProj functions here would return an object of class
> "CRS" and "proj4"/"wktProj". The thing that's nagging me now is the
> use of a function called CRS that isn't a constructor for CRS objects,
> so maybe:
>
> setCRS(foo)=proj4("+init=epsg:4326")
>
>
I would not go there (see above). The fewer function/method names (to
remember) the better.



> Hmm.
>
> Barry
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

