converting geographic to projected CRS

I've had a look at previous posts related to this but the examples don't work for me.

Ive a raster layer that I need to convert to a projected crs so I can use the movecost plugin.

My raster in QGIS looks like this:

Name EPSG:4326 - WGS 84
Units Geographic (uses latitude and longitude for coordinates)
Type Geographic (2D)
Method Lat/long (Geodetic alias)
Celestial Body Earth
Accuracy Based on World Geodetic System 1984 ensemble (EPSG:6326), which has a limited accuracy of at best 2 meters.
Reference Dynamic (relies on a datum which is not plate-fixed)

how do I code in RStudio to covert it to a projected crs?

Apologies if its a dopes question, I'm new to RStudio but have spent weeks on this so far.

Hi @curtis913

could you post some example data. Your question is just to generic to give you any code examples.

Sure, no problem:

library(gstat)
library(movecost)
library(raster)
library(sf)

medmap=raster("//Users/Tony/Documents/PhD/Cardiff/QGIS/Own Layers/Cropped Maps/Elevation Italy and Spain.tif")

Carthago Nova Lat and Long

cn_lat <- -0.9834109
cn_long <- 37.60254

Saguntum Lat and Long

sag_lat <- -0.2761548
sag_long <- 39.67878

orig_points <- SpatialPoints(coords = cbind(cn_lat,cn_long))
dest_points <- SpatialPoints(coords = cbind(sag_lat,sag_long))

movecost(
dtm = medmap, #
origin= orig_points, #
destin = dest_points,#
studyplot = NULL, #
barrier = NULL, # A barrier can be added to prevent a route from passing through
plot.barrier = FALSE,# Works with above
irregular.dtm = TRUE,# Indicates an irregular DTM with coastlines and helps prevent attempts to cross water
funct = "t", # t for Toblers on-path hiking function, pcf for Pandolf with Santee correction
time = "h", # Cost in hours or minutes
outp = "c", # Output in Raster or Contours
move = 16, # number of cell connections 4 (rooks case), 8 (queens), 16 (Knight)
field = 0, # value assigned to cells coinciding with barrier (0 by default)
cogn.slp = FALSE, # Cognitive slope, allow choice of route based on hikers perceived, not actual, slope
sl.crit = 10, # Critical slope (in percent). Used by wheeled vehicle cost function
W = 70, # Walkers body weight Kg
L = 46, # Carried load weight in Kg, 46 - heavy infantry, 32 - Balearic
N = 1.20, # Terrain difficulty
V = 0, # set to 0 to allow slope to effect speed
z = 9, # Zoom level for elevation data (9 by default)
return.base = FALSE, # Optional calculation of return route in dotted line
rb.lty = 2, # Type of line used in return.base
breaks = NULL, # Contour interval, if none specified then 1/10 of cost surface used
cont.lab = TRUE, # Optional labeling of contours
destin.lab = TRUE, # Optional labeling of cost at destination
cex.breaks = 0.6, # Set size of cost labels
cex.lcp.lab = 0.6, # Set size of least cost path labels
graph.out = TRUE, # To generate graphical output
transp = 0.5, # Set transparency of slopeshade raster
oneplot = FALSE, # Set if plots to appear in single window
export = FALSE # Can have results exported as GeoTiff file
)

Not sure if the image will appear but its below, label at end point should be hh:mm:ss but its coming out as a decimal due to being a geographic rather than a presentation layer.

Picture 1

This is the raster info from within QGIS:

General


Name Elevation Italy and Spain
Path /Users/Tony/Documents/PhD/Cardiff/QGIS/Own Layers/Cropped Maps/Elevation Italy and Spain.tif
Sidecar file Elevation Italy and Spain.tif.aux.xml
Total size 11.39 MB
Last modified 28 January 2022 13:44:37 GMT (Elevation Italy and Spain.tif.aux.xml)
Provider gdal

Information from provider


Extent -10.0916666666546391,35.0333333333353067 : 21.3166666666661335,48.2249999999967045
Width 3769
Height 1583
Data type Int16 - Sixteen bit signed integer
GDAL Driver Description GTiff
GDAL Driver Metadata GeoTIFF
Dataset Description /Users/Tony/Documents/PhD/Cardiff/QGIS/Own Layers/Cropped Maps/Elevation Italy and Spain.tif
Compression
Band 1 * STATISTICS_APPROXIMATE=YES
  • STATISTICS_MAXIMUM=4206

  • STATISTICS_MEAN=555.65390007493

  • STATISTICS_MINIMUM=1

  • STATISTICS_STDDEV=501.23712905265

  • STATISTICS_VALID_PERCENT=53.54

  • Scale: 1

  • Offset: 0|
    |More information|* AREA_OR_POINT=Area|
    |Dimensions|X: 3769 Y: 1583 Bands: 1|
    |Origin|-10.0916666666546391,48.2249999999967045|
    |Pixel Size|0.008333333333330000814,-0.008333333333330004283|

Coordinate Reference System (CRS)


Name EPSG:4326 - WGS 84
Units Geographic (uses latitude and longitude for coordinates)
Type Geographic (2D)
Method Lat/long (Geodetic alias)
Celestial Body Earth
Accuracy Based on World Geodetic System 1984 ensemble (EPSG:6326), which has a limited accuracy of at best 2 meters.
Reference Dynamic (relies on a datum which is not plate-fixed)

Identification


Identifier
Parent Identifier
Title
Type
Language
Abstract
Categories
Keywords

Extent


CRS EPSG:4326 - WGS 84 - Geographic
Spatial Extent CRS: EPSG:4326 - WGS 84 - Geographic
X Minimum: 0
Y Minimum: 0
X Maximum: 0
Y Maximum: 0
Temporal Extent Start:
End:

Access


Fees
Licenses
Rights
Constraints

Bands


Band count 1

Number Band NoData Min Max
1 Band 1 32767 1.0000000000 4206.0000000000

Contacts


ID Name Position Organization Role Email Voice Fax Addresses
1

References


No links yet.

History


No history yet.

Custom properties


WMSBackgroundLayer false
WMSPublishDataSourceUrl false
embeddedWidgets/count 0
identify/format Value