Issue with Projection and Plot

52 views
Skip to first unread message

Zehidul Hussain

unread,
Mar 22, 2025, 11:18:09 AMMar 22
to ctmm R user group
Hi Chris

I was working on a very small dataset on deer for akde estimation and found this weird issue. As far as I know, the ctmm takes latitude and longitude from the input GPS data file and converts it into a telemetry object. However, after plotting the data, the orientation of the x and y coordinates orientation changes, where x becomes latitude and y becomes longitude. 
For clarification, I have attached the location actual plot vs location ctmm plots. 

Regards
Zehidul 
locations plot from ctmm.png
locations actual plot.png

Cleo Ferreira

unread,
Apr 25, 2025, 5:23:06 AMApr 25
to ctmm R user group
Hi Zehudil, 
I'm not sure if you've solved this yet, but I had the same problem. 
What worked for me was transforming the longitude and latitude into a Cartesian (meter-based) projection and then exporting it as a new csv file.

This is the code I used:

library(ctmm)
library(dplyr)
library(sf)
library(ggplot2)
library(sf)
library(rgdal)
library(sp)

#load data
data <- read.csv("your_data.csv")
str(data)

# Rename columns for easier use with ctmm if needed
colnames(data)[which(names(data) == "location.lat")] <- "latitude"
colnames(data)[which(names(data) == "location.long")] <- "longitude"
colnames(data)[which(names(data) == "individual.local.identifier")] <- "ID"  # if necessary

# Define the UTM projection (e.g., Zone 35S for South Africa)
utm_crs <- st_crs(32735)

# Convert your data frame to an sf object
sf_data <- st_as_sf(data, coords = c("longitude", "latitude"), crs = 4326)

# Transform to UTM (to get coordinates in meters)
sf_data_utm <- st_transform(sf_data, crs = utm_crs)

# Extract UTM coordinates
utm_coords <- st_coordinates(sf_data_utm)

# Add UTM coordinates (easting and northing) to your data, this is the Cartesian projection values
data$utm_easting <- utm_coords[, 1]
data$utm_northing <- utm_coords[, 2]

# Save the updated data frame to a new CSV file
write.csv(data, "your_data_new_csv_name.csv", row.names = FALSE)

#loading in the new csv file with updated UTM values)
data2 <- read.csv(" your_data_new_csv_name .csv")

#rename other columns if needed
colnames(data2)[which(names(data) == "utm_easting")] <- "x"
colnames(data2)[which(names(data) == "utm_northing")] <- "y"
colnames(data2)[which(names(data2) == "individual.local.identifier")] <- "ID"

# Convert data to telemetry object with correct projection (UTM Zone 35S), set the CRS as needed 
tel <- as.telemetry(data2, projection = CRS("+init=epsg:32735"))
plot(tel)

I hope this helps,
All the best, 
Cleo

Christen Fleming

unread,
May 21, 2025, 10:06:30 PMMay 21
to ctmm R user group
Hi Zehidul & Cleo,

This is because the default projection is 2-point equidistant, which rotates the coordinate system.

Please see help("projection")

Best,
Chris
Reply all
Reply to author
Forward
0 new messages