[R-sig-Geo] Did I correctly convert my data from UTM zone 12 to 11?
Alexander Ilich
@|||ch @end|ng |rom u@|@edu
Tue Aug 8 20:46:59 CEST 2023
If the vast majority of your data was within one UTM zone and only a small amount bled over into the adjacent UTM zone then it'd probably just be ok to choose the one that contains the majority of your data and accept that there will be some distortion. Since it's roughly 50/50 though, you should either split the data into two data sets and perform calculations separately for each one, or transform them to a common projection (e.g. EPSG:4326 aka WGS84 aka lat/lon) and then perform the analysis. Most of this has been stated already, but I figured I'd point you to some tools as well that may help you. Rather than doing some work arounds that seem to get it to look right it'd be better to use tools specifically to transform between different projections. Based on what you wrote it seems like you're working with vector data. For vector data, the sf package in R is very comprehensive (though terra also has vector capabilities). The st_crs will let you check or manually set a projection for a data set, and the st_transform function will let you transform from one projection to another. Note the difference here is that st_crs will not change the coordinates, it will just assign the name of the coordinate system whereas st_transform will convert from one to the other. UTM is convenient in certain cases because it can make calculations simpler since you can assume the area is essentially flat over the space considered. That being said, the sf package many calculations can now be done using spherical geometry<https://r-spatial.org/book/04-Spherical.html> which will be more accurate (I'm not sure about google earth engine though as I haven't used it). Below is some R code to take a dataframe of coordinates (like from your CSV), define the projection as UTM 11 or UTM 12 in separate objects, and how to transform them to lat/lon and combine them into a single object.
``` r
library(sf)
#> Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE
# Create Data frames of points (Here you would use read.csv)
UTM11<- data.frame(X = c(358334, 571173, 446818, 576082, 331892),
Y = c(5128282, 5105900, 4730385, 4667181, 4811548))
UTM12<- data.frame(X = c(405776, 614821, 428211, 602751, 366593),
Y = c(5132654, 5117139, 4841550, 4704516, 4625745))
#Have 2 separate objects with different crs
UTM11<- st_as_sf(UTM11, coords = c("X", "Y"))
st_crs(UTM11)<- "EPSG:32611" #Set crs (https://epsg.io/32611)
UTM12<- st_as_sf(UTM12, coords = c("X", "Y"))
st_crs(UTM12)<- "EPSG:32612" #Set crs (https://epsg.io/32612)
#Transform to common crs and merge
WGS84<- rbind(st_transform(UTM11, crs = "EPSG:4326"),
st_transform(UTM12, crs = "EPSG:4326"))
```
<sup>Created on 2023-08-08 with [reprex v2.0.2](https://reprex.tidyverse.org)</sup>
________________________________
From: R-sig-Geo <r-sig-geo-bounces using r-project.org> on behalf of Jason Edelkind via R-sig-Geo <r-sig-geo using r-project.org>
Sent: Sunday, August 6, 2023 4:23 PM
To: r-sig-geo using r-project.org <r-sig-geo using r-project.org>
Subject: [R-sig-Geo] Did I correctly convert my data from UTM zone 12 to 11?
hello, first time user here and aspiring grad student. I have a set of location data that I�ve been trying to import into google earth engine from R as a CSV file. The problem is that about half of my data is from utm zone 12, and the other half is from utm zone 11. When I import my original data into google earth engine, the zone 11 data is shifted over to the right because I use utm zone 12 as the crs in R. After some reading into the definition of a utm zone, I tried to just subtract 6 from the zone 11 latitude values after first converting them to a lon/lat format. This appears to have worked as on first glance all of the zone 11 points are where they should be, however it feels like too easy a fix for me after struggling with this for several days. So my question is, is this an acceptable way to convert my data, or am I doing something wrong that could result in inaccurate location data? Thanks!
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo using r-project.org
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=05%7C01%7Cailich%40usf.edu%7Cf73b5985c9d543c03e7508db96bb0824%7C741bf7dee2e546df8d6782607df9deaa%7C0%7C0%7C638269502289723854%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=T2BxWF1rCQPJmqKsVkbFR4%2F8xXrEh5iXM0XjhO634gc%3D&reserved=0<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
[EXTERNAL EMAIL] DO NOT CLICK links or attachments unless you recognize the sender and know the content is safe.
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list