1

I am using these data and I am able to draw a map with them using the R package sf:

## R code
library(sf)
hdf <- st_read(dsn = "./communes/communes.shp")
plot(hdf[, 1])

map of region Hauts-de-France

Now, I want to represent a given latitude/longitude location on the map. For example this one:

  • 50°36'38.0"N 3°02'02.5"E
  • 50.610559, 3.034038

More precisely, I want to know if it is possible with these data or if they are lacking necessary metadata to fit with the latitude/longitude system?

1
  • 1
    Which software to you want to user to represent lat/lon data with ? What you should be doing here is check what coordinates system (CRS) is used used in your file (R seems to be able to provide that). Or open the .prj file related to your Shapefile (which says its Lambert 93, standard for French data). I have no knowledge in R, but it should be capable of doing so. It knows that your Communes are in Lambert93, if you give it a point in Lat/Lon telling it is (CRS 4326) it should show up fine (r-spatial.github.io/sf/reference/st_crs.html)
    – Kasper
    Commented Dec 19, 2022 at 16:09

1 Answer 1

1

To transform the projection from WGS84 to Lambert 93, you could do this in R as:

library(sf)

# Create an example with coordinates you provided
> point_1 <- st_sfc(st_point(c(50.610559, 3.034038)))

# Set the CRS to WGS (long and lat)
> st_crs(point_1) <- 4326

# Print object
> point_1
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 50.61056 ymin: 3.034038 xmax: 50.61056 ymax: 3.034038
Geodetic CRS:  WGS 84
POINT (50.61056 3.034038)

# Read in the communes shapefile that you linked
> comun <- read_sf("Downloads/communes/communes.shp")

> comun
Simple feature collection with 3789 features and 9 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 583916.5 ymin: 6859784 xmax: 790288.4 ymax: 7110479
Projected CRS: RGF93 v1 / Lambert-93
# A tibble: 3,789 × 10
   gml_id        oid  code nom           nom_min  statut surfa…¹ popul…² popul…³
   <chr>       <dbl> <dbl> <chr>         <chr>    <chr>    <dbl>   <dbl>   <dbl>
 1 communes.1      1 80427 HEM-HARDINVAL Hem-Har… Commu…      10     358     351

# The transform from WGS to RGF93 v1, the projection in comun
> point_1_new <- st_transform(point_1, st_crs(comun))

# Print the new object
> point_1_new
Geometry set for 1 feature 
Geometry type: POINT
Dimension:     XY
Bounding box:  xmin: 7115835 ymin: 3336758 xmax: 7115835 ymax: 3336758
Projected CRS: RGF93 v1 / Lambert-93
POINT (7115835 3336758)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.