[R-sig-Geo] Proj4 - latitude or longitude exceeded limits
Roger Bivand
Roger.Bivand at nhh.no
Tue Jan 17 19:50:00 CET 2017
On Tue, 17 Jan 2017, aurelie.tschopp at vetsuisse.unibe.ch wrote:
> Dear all,
>
> I am analysing GPS Data from Chad. I need to first project the latitude
> and longitudes. I use the package Proj4, the function project for this.
> I have 2 devices and with the data of the 1st device, the projection
> worked perfectly. But with the data from the other device, I got this
> error message: "Error in project(loc, "+proj=utm +zone=33 +ellps=WGS84
> +datum=WGS84 +units=m +no_defs") : latitude or longitude exceeded
> limits"
>
> I found that Chad was UTM 33P (Wikipedia UTM:
> https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system
> ), but some people could use the notification 33N: 33 for the zone and N
> for the North hemisphere.
>
> My code is:
> loc <- dat[,c("Longitude","Latitude")
> loc_Zone33 <- project(loc, "+proj=utm +zone=33 +ellps=WGS84 +datum=WGS84
> +units=m +no_defs")
>
> Does anybody know where my problem could be?
Well, the error message is coming from inside the proj.4 library: did you
look at the input object? If one device was returning decimal geographical
coordinates and the other a string with degrees, minutes and seconds in
one "number":
library(rgdal)
project(matrix(c(19.0, 15.0), nrow=1), "+proj=utm +zone=33 +ellps=WGS84")
project(matrix(c(1900, 1500), nrow=1), "+proj=utm +zone=33 +ellps=WGS84")
In this setting I get:
> project(matrix(c(19.0, 15.0), nrow=1), "+proj=utm +zone=33
+ellps=WGS84")
[,1] [,2]
[1,] 930334.7 1662218
> project(matrix(c(1900, 1500), nrow=1), "+proj=utm +zone=33
+ellps=WGS84")
[,1] [,2]
[1,] Inf Inf
Warning message:
In project(matrix(c(1900, 1500), nrow = 1), "+proj=utm +zone=33
+ellps=WGS84") :
1 projected point(s) not finite
but not your error. I suspect that the matrix you are passing contains
non-geographical coordinates. If you are using the proj4 package (odd
choice but there you are):
> library(proj4)
> project(matrix(c(19.0, 15.0), nrow=1), "+proj=utm +zone=33
+ellps=WGS84")
[,1] [,2]
[1,] 930334.7 1662218
> project(matrix(c(1900, 1500), nrow=1), "+proj=utm +zone=33
+ellps=WGS84")
Error in project(matrix(c(1900, 1500), nrow = 1), "+proj=utm +zone=33
+ellps=WGS84") :
latitude or longitude exceeded limits
confirming that it doesn't handle exceptions other than by a hard fail.
Roger
> Thank you
> Aurélie
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand at nhh.no
http://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en
http://depsy.org/person/434412
More information about the R-sig-Geo
mailing list