On Tue, 29 Nov 2011, Sam Rabin wrote:

Hello all. I'm trying to write a new shapefile and am running into a weird 
issue. After I import the new shapefile into QGIS, I can see all the polygons 
in the attribute table, but none of them show up on the map no matter how I 
play with the projections.

Here is some code that isolates the problem:
library("maptools")
spdf_1 <- readShapePoly("original.shp")
spdf_2 <- readShapePoly("original.shp", proj4string=CRS(as.character("+proj=utm 
+zone=19 +south +datum=WGS84 +units=m +no_defs")))
writeSpatialShape(spdf_1, "output_1")
writeSpatialShape(spdf_2, "output_2")

As you can see, I tried readShapePoly with and without CRS information, but both output files exhibit the same problem. I've used writeSpatialShape successfully in the past, and I don't know what I'm doing differently here.

The functions in maptools neither read nor write *.prj files, only *.shp, *.shx, and *.dbf (they use shapelib, which doesn't know about projections). Setting the CRS makes no difference. Did you use writeOGR() in rgdal before - the rgdal functions both read and write projection information?

Hope this helps,

Roger


Thanks in advance for your help.

Sam Rabin
    Graduate student
        Princeton University
        Ecology & Evolutionary Biology
        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
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: [email protected]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to