[R-sig-Geo] Proj4 - latitude or longitude exceeded limits

Michael Sumner mdsumner at gmail.com
Tue Jan 17 21:48:17 CET 2017


Watch out with proj4 btw, it has an obscure bug where a 2 row matrix input
is transposed, mixing longitude and latitude in a way that triggers an out
of bounds error for latitude, only when the mixed abs(longitude) is greater
than 90.

Use the sf package, or rgdal, or mapproj.

Cheers, Mike

On Wed, Jan 18, 2017, 05:51 Roger Bivand <Roger.Bivand at nhh.no> wrote:

> 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
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
> University of Tasmania Electronic Communications Policy (December, 2014).
> This email is confidential, and is for the intended recipient only.
> Access, disclosure, copying, distribution, or reliance on any of it by
> anyone outside the intended recipient organisation is prohibited and may be
> a criminal offence. Please delete if obtained in error and email
> confirmation to the sender. The views expressed in this email are not
> necessarily the views of the University of Tasmania, unless clearly
> intended otherwise.
> .
>
-- 
Dr. Michael Sumner
Software and Database Engineer
Australian Antarctic Division
203 Channel Highway
Kingston Tasmania 7050 Australia

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list