[R-sig-Geo] finding CRS from latitude/longitude

Tom Gottfried tom.gottfried at o2mail.de
Sat Oct 6 19:54:34 CEST 2012


... and you can forget about my previous answer: "+ellps=WGS84" is 
assumed if nothing else is given:

library(sp)
library(rgdal)
spTransform(SpatialPoints(data.frame(x=1:10, y=1:10),
	proj4string=CRS("+proj=latlong +datum=potsdam")),
	CRS("+proj=merc"))

Sorry for the spam!
Tom

Am 06.10.2012 19:19, schrieb Robert J. Hijmans:
> Alemante,
>
>> but I keep on getting the message that CRS is wrong.
>> Coordinate Reference System (CRS) arguments: NA
>
> Please show more complete code. Which object are you talking about? Some of
> the object you create have a CRS (SP) others do not.(pts, F1), which is
> pretty obvious from reading the sequence of events in your code. You set
> the CRS for SP, but then you use F1 again which does not have a CRS and
> therefore neither do the objects derived from it. You could do
> after, gridded(F1) = TRUE,  proj4string(F1)<- CRS("+proj=longlat")
>
>
>> Could you please advice me on how I can get it right?
>
> I need to guess, but I think you want to transform points, in that case, do
> this:
>
> # example data
> x<- 1:10
> y<- 1:10
>
> F1<-data.frame(x, y)
> library(sp)
> SP<- SpatialPoints(F1,proj4string=CRS("+proj=longlat"))
>
> library(rgdal)
> spt<- spTransform(SP, CRS("  fill in  the proj4 string you want  ") )
>
>
> Best, Robert
>
>
> On Sat, Oct 6, 2012 at 5:48 AM, alemante zd<mintibezabih at gmail.com>  wrote:
>
>> Dear all,
>>
>> I would like to sp transform my latitude/longitude vector to by first
>> telling it what CRS it is. This is what I did.
>>
>> F1<-data.frame(x, y)
>> coordinates(F1)=~x+y
>> SP<-SpatialPoints(F1,proj4string=CRS("+proj=longlat"))
>> pts = SpatialPixels(SpatialPoints(F1))
>> gridded(F1) = TRUE
>>
>> but I keep on getting the message that CRS is wrong.
>> Coordinate Reference System (CRS) arguments: NA
>>
>> Could you please advice me on how I can get it right?
>>
>> cheers
>> minti
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Indo-German Centre for Sustainability
Indian Institute of Technology Madras
600 036 Chennai, India
www.igcs-chennai.org



More information about the R-sig-Geo mailing list