[R-sig-Geo] LatLong to UTM

rscardamaglia at ege.fcen.uba.ar rscardamaglia at ege.fcen.uba.ar
Wed Jun 6 22:45:08 CEST 2012


A million thanks Piero and Robert! Problem solved.

Best wishes,

Romina.


>> I do not think the issue is a reversal of lat and lon (but using Y for
>> longitude is very confusing!). In Romina's example there is a difference
>> of 10000000 meters in northing. I.e. the number she expected uses a
>> 'false
>> northing'
>>
>> Romina used:
>> "+proj=utm +zone=21 ellps=WGS84"
>>
>> Piero fixed the problem by using (via an epsg code)
>> "+proj=utm +zone=21 +south +ellps=WGS84 +datum=WGS84"
>>
>> note the "+south" to get the false northing.
>>
>> Robert
>>
>> On Wed, Jun 6, 2012 at 9:23 AM, Piero Campalani
>> <piero.campa at gmail.com>wrote:
>>
>>> Hi Romina,
>>> looking at { http://spatialreference.org/ref/epsg/32721/ } I can see
>>> the
>>> UTM zone 21H or also 21S for South spans longitudes in the range
>>> (-80,-60)
>>> so I guess you just inverted easting and northing in your code:
>>>
>>> So:
>>>  $ LatLong <- data.frame(Y=-35.14189, X=-57.39206)  # <--  X is the
>>> LONGITUDE.
>>>  $ coordinates(LatLong) <- ~ X+Y
>>>  $ proj4string(LatLong) <- CRS("+init=epsg:4326")
>>>  $ Utm <- spTransform(LatLong, CRS("+init=epsg:32721"))
>>>  $ Utm
>>>
>>>    SpatialPoints:
>>>                X       Y
>>>    [1,] 464285.6 6111151
>>>
>>> Cheers,
>>> Piero
>>>
>>>
>>>
>>>
>>> In general anyway, it's safer to identify CRS by EPSG code -- which in
>>> your
>>> case is 32721 (http://spatialreference.org/ref/epsg/32721/) --, then
>>> you
>>> can create it like this:
>>>
>>>    $ Utm <- spTransform(LatLong, CRS("+init=epsg:32721"))
>>>
>>>
>>>
>>> On 6 June 2012 17:57, <rscardamaglia at ege.fcen.uba.ar> wrote:
>>>
>>> > Hello,
>>> > I need some help transforming Latitude Longitude coordinates (in
>>> decimal
>>> > degrees) to UTM (zone 21 H, since I’m in Buenos Aires, Argentina).
>>> > This is the script I used. The transformation for the easting
>>> coordinates
>>> > is correct but not for the Northing.
>>> >
>>> > > LatLong <- data.frame(X = coordenadas2[,1], Y = coordenadas2[,2])
>>> > > LatLong
>>> >          X         Y
>>> > 1 -35.14189 -57.39206
>>> > 2 -35.14072 -57.39421
>>> > 3 -35.14507 -57.38274
>>> > 4 -35.14390 -57.39083
>>> > 5 -35.14496 -57.39312
>>> > 6 -35.14069 -57.39280
>>> > 7 -35.14241 -57.39119
>>> >
>>> > > coordinates(LatLong) <- ~ Y + X
>>> > > proj4string(LatLong) <- CRS("+proj=longlat +ellps=WGS84
>>> +datum=WGS84")
>>> > > Utm <- spTransform(LatLong, CRS("+proj=utm +zone=21 ellps=WGS84"))
>>> > > Utm
>>> >
>>> > SpatialPoints:
>>> >            Y        X
>>> > [1,] 464285.6 -3888849
>>> > [2,] 464089.3 -3888720
>>> > [3,] 465136.0 -3889198
>>> > [4,] 464398.6 -3889071
>>> > [5,] 464190.4 -3889189
>>> > [6,] 464217.7 -3888716
>>> > [7,] 464365.1 -3888906
>>> >
>>> > Coordinate Reference System (CRS) arguments: +proj=utm +zone=21
>>> > +ellps=WGS84
>>> >
>>> > It seems the Easting coordinates are well transformed, but the
>>> Northing
>>> > should be around 6111151.35 m S (for the first one for example).
>>> > I would really appreciate some help.
>>> > Best wishes,
>>> >
>>> > Romina.
>>> >
>>> > _______________________________________________
>>> > 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
>>>
>>>
>>
>



More information about the R-sig-Geo mailing list