An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120111/7f7485a5/attachment.pl>
Plotting shapefiles in R
5 messages · Ester Polaina Lacambra, celso at stephan.mus.br, Roger Bivand +2 more
Try this:
## read polygon SHP
library(shapefiles)
poli<-read.shapefile("your shp file name")
poli<-convert.to.simple(poli$shp)
poli<-poli[,-1]
plot(poli)
Hello, I am trying to perform several spatial analysis on R, based on polygon lists. My data come from ArcGIS, being in shape format. I would like to create a polygon list from this file. Apparently, R reads properly the file by using the function "read.shapefile", however when I try the function "plot" on this object, the program does not recognize which are the X and Y coordinates (which -by the way- are in decimal degree units). Should I use any specific sintaxis to indicate which columns are my coordinates? or maybe I have to project my coordinates somehow? Thank you very much indeed, -- Ester [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
On Wed, 11 Jan 2012, celso at stephan.mus.br wrote:
Try this:
Please note that the shapefiles package has not been revised since 2006, and does not use sp classes, so you are completely stuck with the import data representation of that package. See the "Spatial" task view on CRAN for better supported alternatives. Roger
## read polygon SHP
library(shapefiles)
poli<-read.shapefile("your shp file name")
poli<-convert.to.simple(poli$shp)
poli<-poli[,-1]
plot(poli)
Hello, I am trying to perform several spatial analysis on R, based on polygon lists. My data come from ArcGIS, being in shape format. I would like to create a polygon list from this file. Apparently, R reads properly the file by using the function "read.shapefile", however when I try the function "plot" on this object, the program does not recognize which are the X and Y coordinates (which -by the way- are in decimal degree units). Should I use any specific sintaxis to indicate which columns are my coordinates? or maybe I have to project my coordinates somehow? Thank you very much indeed, -- Ester [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no
Roger didn't say it (but he wrote the book on it), but an alternative
would be something like:
library(sp)
library(rgdall)
poli<-readOGR("directory","shapefilename without .shp")
class(poli) # SpatialPolygonsDataFrame
proj4string(poli) # projection information
spplot(poli)
One advantage is that by using sp classes, this approach allows you to
reproject via spTransform(), colorize polygons by values of an
attribute in the dataframe in spplot(), and actually do more things
with the spatial data.
Tom 2
1 day later
Dear Ester,
This is a simple, yet effective, approach:
library(maptools)
myshp<-readShapePoly("path_to_your_shapefile")
plot(myshp)
Hope it helps,
Thiago.
--- On Wed, 11/1/12, Ester Polaina Lacambra <e.polaina at gmail.com> wrote:
From: Ester Polaina Lacambra <e.polaina at gmail.com> Subject: [R-sig-Geo] Plotting shapefiles in R To: r-sig-geo at r-project.org Date: Wednesday, 11 January, 2012, 7:20 Hello, I am trying to perform several spatial analysis on R, based on polygon lists. My data come from ArcGIS, being in shape format. I would like to create a polygon list from this file. Apparently, R reads properly the file by using the function "read.shapefile", however when I try the function "plot" on this object, the program does not recognize which are the X and Y coordinates (which -by the way- are in decimal degree units). Should I use any specific sintaxis to indicate which columns are my coordinates? or maybe I have to project my coordinates somehow? Thank you very much indeed, -- Ester ??? [[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo