Help plotting Geographic Data in R using PBSMapping and Shapefiles

让人想犯罪 __ 提交于 2019-12-04 05:42:10
Shane

You may also want to look at these related questions, especially at Eduardo's responses:

Seems like PBSmapping uses some crude heuristics to work out the projection from the .prj file. (see help(importShapefile)). I personally don't understand all the stuff inside a prj file but using this website www.spatialreference.org I reckon your map matches

http://www.spatialreference.org/ref/epsg/26912/

Whenever I get a new shape file I find it's projection system on this website and then look for the proj4 string, which in this case is "+proj=utm +zone=12 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"

(Like I said I don't know PBSmapping, but you can read this in using maptools as follows)

library(maptools)
sf=readShapeSpatial("SGID93_DEMOGRAPHIC_CensusTracts2000.shp",proj4string=CRS("+proj=utm +zone=12 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"))

and then convert to latlong using

library(rgdal)

sftransformed=spTransform(sf,CRS("+proj=longlat"))

and

plot(sftransformed,axes=T)

gives a plot with the right units on the axes.

Not sure if PBSmapping understands a proj4 string? Looks like it doesn't to be honest.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!