0
votes

I would like to project the coordinates of the 2012 Peruvian census to work with another raster layer that has the following coordinates reference system :

"+proj=utm +zone=18 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ".

The answer of the post https://gis.stackexchange.com/questions/31743/projecting-sp-objects-in-r did not work in my case.

crs(census)

CRS arguments: +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0

newCRScensus=CRS("+proj=utm +zone=18 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ") 
projcensus=spTransform(census,crs=newCRScensus)

Error in spTransform(census, crs = CRS("+proj=utm +zone=18 +south +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs ")) : second argument needs to be of class CRS

I don't understand the error message since the second argument is indeed of class CRS.

Any suggestions for another way of projecting the geographical coordinates is welcomed.

1

1 Answers

1
votes

The second argument of spTransform is called CRSobj, not crs, so the right call should be either

projcensus=spTransform(census, newCRScensus)

or

projcensus=spTransform(census, CRSobj = newCRScensus)