I try to fit my shape to the google map.


in.dir <- getwd()

    sh <- readOGR(in.dir, layer = "Ytor", 
p4s = "+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +units=m +no_defs")

sh2 <- spTransform(sh, CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +no_defs"))


 sh2.df <- fortify(sh2)


swe <- get_map(location = c(15.3, 63.63, 15.5, 63.68),  maptype = 'satellite')
ggmap(swe) + geom_polygon(aes(x = as.numeric(long), y = as.numeric(lat), group = group), data = df, color = "white", fill = "white", alpha = 0.1) 

Finally I got the map as belowenter image description here

The borders of the shape are not going as the ggmap borders. What did I wrong that the borders does not fit?

  • I once experienced problems with the projection of my data when using readOGR alongside with Google Maps data. Try to manually add the projection of layer "Ytor" (argument p4s) to readOGR and crosscheck the visualization afterwards.
    – fdetsch
    Commented Sep 17, 2015 at 8:54
  • Do I get it right? I should set the p4s argument in the function readOGR. How the argument should look like? Commented Sep 17, 2015 at 10:18
  • Just like the output of proj4string, I suppose. It's detailed in ?readOGR. At least it's worth trying, helped me out back then.
    – fdetsch
    Commented Sep 17, 2015 at 12:53
  • @fdetsch I edited question. I added argument p4sin the readOGR function but it did not help? Did I make it right? Commented Sep 18, 2015 at 5:37
  • Yeah, it's correct. As I said, it was worth trying. Maybe somebody else knows what the problem is then.
    – fdetsch
    Commented Sep 18, 2015 at 5:54

1 Answer 1


Your projection string has no towgs84 parameters.

Assuming your data is in EPSG:3021 RT90 2.5 gon V, it should be:

+proj=tmerc +lat_0=0 +lon_0=15.80827777777778 +k=1 +x_0=1500000 +y_0=0 +ellps=bessel +towgs84=414.1,41.3,603.1,-0.855,2.141,-7.023,0 +units=m +no_defs

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.