3

I am trying to convert a global map shapefile from a geographical coordinate system (lat/long, WGS84) into UTM projection using the following code:

setwd = "~/Desktop/Maps"
wmap = readOGR(dsn="world_map", layer="world_map") 
wmap_utm = spTransform(wmap, CRS("+proj=utm"))

Unfortunately, I keep getting the following error code:

non finite transformation detected:
[1] 111.01052  19.68381       Inf       Inf
Error in .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args,  : 
  failure in Polygons 3 Polygon 1 points 1
In addition: Warning message:
In .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args,  :
  686 projected point(s) not finite

I have read both of the following questions on this topic, but both are related to small data examples rather than shapefiles with lots of data points: rgdal package lat/long -> UTM ; "Non Finite Transformation Detected" in spTransform in rgdal R Package. I have some polygon files in UTM format that I wish to add to the map and I really need a UTM projection. Any advise on what I might be doing wrong or ways to rectify the problem would be greatly appreciated.

Community
  • 1
  • 1
Emily
  • 859
  • 5
  • 14
  • 31
  • 1
    I think UTM is not one projection that can applied to the whole world; rather there are UTM zones. Hence I believe you need to find out the UTM zone of your region first, and then find out how to add this information to the `CRS`. – Karsten W. Feb 15 '14 at 01:21
  • 3
    UTM has a very narrow range, ~6 deg of longitude, not suitable for global data. You could crop the global data to a suitable bounds with gIntersection in rgeos, then transform it. – mdsumner Feb 15 '14 at 01:24
  • 1
    Can you upload your world shapefile and one of your UTM polygon files somewhere (Dropbox??) and provide a link?? This way you're more likely to get an answer that solves your specific problem. – jlhoward Feb 15 '14 at 03:14
  • 1
    Thanks all! I guessed that would be the case. I am used to mapping in arcGIS where this can be done easily. Just learning how to map in R! @ midsummer: your rgeos suggestion worked very well using the following example: http://stackoverflow.com/questions/13982773/crop-for-spatialpolygonsdataframe. Thanks! – Emily Feb 15 '14 at 17:48

0 Answers0