Bruno Guarita
Bruno Guarita

Reputation: 817

Convert Longitude / Latitude coordinates to Lambert conformal conic projection

I am not an expert with maps and coordinate systems. I need to convert longitude and latitude coordinates into LCC (Lambert conformal conic projection). I have a list of city coordinates that I need to plot in a map. The problem is that the projection of the map is "+proj=lcc +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs".

What can I do so that the longitude and latitude coordinates are converted into the projection of the map?

Below a tibble with the cities and the coordinates:

cities <- tibble(city.name = c('Lisbon', 'Barcelona', 'Brussels'),
                 lon = c(-9.139337,2.173404,4.351710),
                 lat = c(38.72225,41.38506,50.85034))

How can I convert these coordinates into coordinates according to the projection of the map?

"+proj=lcc +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs"

Thanks!

Upvotes: 0

Views: 2009

Answers (1)

Charlie Gallagher
Charlie Gallagher

Reputation: 616

You can use the sf package, which has sf::st_transform(). This projects the coordinates in an sf object.

library(tidyverse)
library(sf)

cities <- tibble(city.name = c('Lisbon', 'Barcelona', 'Brussels'),
                 lon = c(-9.139337,2.173404,4.351710),
                 lat = c(38.72225,41.38506,50.85034))

city_proj <- "+proj=lcc +lat_1=43 +lat_2=62 +lat_0=30 +lon_0=10 +x_0=0 +y_0=0 +ellps=intl +units=m +no_defs"

cities <- st_as_sf(cities, coords = c(2, 3))
st_crs(cities) <- 4326
cities <- st_transform(cities, crs = city_proj)

ggplot(cities) + 
  geom_sf()

Edit: Changed initial CRS to a standard one. This makes the transformation make more sense.

Upvotes: 2

Related Questions