You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having a little problem with the distance function. When I apply it on two SpatVector objects that have CRS WGS84 (EPSG:4326), the results it returns don't seem to be in meters or km. Maybe I am forgetting some intermediate step, but I don't know which one exactly. I leave my script and the reproducible data:
require(terra)
# Read main polygon of Peru
peru <- vect(x = "gadm41_PER.gpkg",
layer = "ADM_ADM_0")
# Convert lon/lat coordinates
read.csv(file = "lonlat_pts.csv") |>
# Convert to SpatVector object
vect(crs = "EPSG:4326") |>
# Calculate distances in meters
distance(y = peru, unit = "m")
When I change the unit argument from m to km, the results are divided by 1000 (logically), but the values are not correct and seem to be affected on a scale of ~105. That is, 1m in the result (of the script) represents ~105m in reality.
If x is a SpatVector: The distance is always expressed in meter, except when the coordinate reference system is longitude/latitude AND one of the SpatVector(s) consists of lines or polygons. In that case the distance is in degrees, and thus not very useful (this will be fixed soon).
Hello.
I am having a little problem with the
distance
function. When I apply it on twoSpatVector
objects that have CRS WGS84 (EPSG:4326), the results it returns don't seem to be in meters or km. Maybe I am forgetting some intermediate step, but I don't know which one exactly. I leave my script and the reproducible data:When I change the
unit
argument fromm
tokm
, the results are divided by 1000 (logically), but the values are not correct and seem to be affected on a scale of ~105. That is, 1m in the result (of the script) represents ~105m in reality.Data:
I'm using the latest (Github) version of terra: 1.7.82
The text was updated successfully, but these errors were encountered: