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

Michael Sumner mdsumner at gmail.com
Wed Jan 18 11:11:25 CET 2017


Yes that's it, I sent it to the maintainer as a report, and parked my
example here:

https://github.com/mdsumner/proj4/issues/1

I planned to patch it there but can now confirm your fix solves that issue.

(I wasn't sure anyone at all else would even notice so was waiting for the
maintainer).

Thanks for the confirmation and fix.

Thanks, Mike

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

> On Tue, 17 Jan 2017, Michael Sumner wrote:
>
> > 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.
>
> You mean:
>
> > library(rgdal)
> > crds <- rbind(c(90, 1), c(91, 2))
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
>           [,1]     [,2]
> [1,] 833927.9 110682.8
> [2,] 945193.9 221604.0
> > crds <- rbind(c(90, 1), c(91, 2), c(92, 3))
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
>            [,1]     [,2]
> [1,]  833927.9 110682.8
> [2,]  945193.9 221604.0
> [3,] 1056324.8 332866.1
> > crds <- matrix(c(91, 2), nrow=1)
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
>           [,1]   [,2]
> [1,] 945193.9 221604
>
> and
>
> > library(proj4)
> > crds <- rbind(c(90, 1), c(91, 2))
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
> Error in project(crds, "+proj=utm +zone=45 +ellps=WGS84") :
>    latitude or longitude exceeded limits
> > crds <- rbind(c(90, 1), c(90, 2))
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
> Error in project(crds, "+proj=utm +zone=45 +ellps=WGS84") :
> > crds <- rbind(c(90, 1), c(91, 2), c(92, 3))
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
>            [,1]     [,2]
> [1,]  833927.9 110682.8
> [2,]  945193.9 221604.0
> [3,] 1056324.8 332866.1
> > crds <- matrix(c(91, 2), nrow=1)
> > project(crds, "+proj=utm +zone=45 +ellps=WGS84")
>           [,1]   [,2]
> [1,] 945193.9 221604
>
> right?
>
> I'll take a look and if I see the bug, send a patch to Simon. Please
> confirm that this is what you see.
>
> Best wishes,
>
> Roger
>
> >
> > 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 <+47%2055%2095%2093%2055>; 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.
> >> .
> >>
> >
>
> --
> Roger Bivand
> Department of Economics, Norwegian School of Economics,
> Helleveien 30, N-5045 Bergen, Norway.
> voice: +47 55 95 93 55 <+47%2055%2095%2093%2055>; 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

-- 
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