I am trying to apply a projection to the following dataset from the USGS: https://www.sciencebase.gov/catalog/item/581d052be4b08da350d524ce. After reading in the dataset, the "proj4string" slot shows the data has these CRS arguments:

+proj=longlat +datum=NAD83 +no_defs +ellps=GRS80 +towgs84=0,0,0

Here is a simplified piece of code that results in the error in question:

Highway_longlat <- readOGR(dsn = "SourceFolder")
Highway_merc <- spTransform(x = Highway_longlat, CRSobj = CRS(projargs = "+proj=merc"))
map(database = Highway_merc)

I get this error:

Error in par(pin = p) : invalid value specified for graphical parameter "pin"

I was not able to find any information on this error that seemed related to my situation.

  • The command plot(Highway_merc) produces the expected image with no error so it seems like the error is not coming from spTransform but rather from the map function. Commented Mar 7, 2017 at 21:30

1 Answer 1


Usually one would define the projection in R, before applying spTransform. Did you try this?

coordinates(highway_longlat) <- ~long+lat #Refers to your Long and Lat columns
proj4string(highway_longlat) <- CRS("+init=epsg:4326") # set it to WGS84
highway_merc <- spTransform(highway_longlat,CRS("+proj=merc")) 
#I usually set it to the EPSG code within the CRS ( ), but the above should work as well
  • I gave it a shot but ran into a couple issues. (1) I think the 'coordinates' function is for a SpatialPointsDataFrame whereas my dataset is a SpatialLinesDataFrame. (2) When applying CRS to proj4string, I get a warning that I am overriding the existing CRS. Thanks for your suggestion. Commented Mar 7, 2017 at 20:47
  • You can exclude the coordinates function. It is optional. If you can e-mail your code to vjjan91 at gmail ; happy to take a look. Commented Mar 7, 2017 at 20:58

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.