On Thu, 7 Jan 2010, Noli Sicad wrote:

# Deleting shapefile polygons that doesn't much with record in the
merge dbf file

I have already told you to use "["

new_obj <- obj[keep,]

where keep may be an integer vector of row numbers, a logical vector of TRUE/FALSE values, or (for newer versions of sp) a negative integer vector of entities to drop. So maybe:

keep <- !is.na(obj$x)

As I said before, think of Spatial*DataFrame objects as data.frame objects and use the same operators as a first approximation which will usually work, as indeed it has to for Spatial*DataFrame objects to function as the data= argument in the (formula, data) S language White Book abstraction that underpins most analysis in S/R.

Roger


I want to do:
1. Delete polygons that doesn't have a match with record in joined /
merge table of the shapefile.
   (Done transpose and merging - joined to one-to-one relationship already.)
2. Create a subset of the polygon and save shapefile or just save the
revise shapefile
3. Open in shapefile in QGIS and do spplot.

~~~~~~~~~~~~~~
from 1 to 93 polygon
  if table ID == polygon_ID then print("Polygon OK")
      else delete the polygon

How do I delete the polygon and save?

~~~~~~~~~~~~~
getwd()
setwd('C:\\Down2\\R_forestmgt\\modelIII\\')

library(rgdal)

forest <- readOGR(".",  "ForestStand")

forest.dat <- slot(forest, "data") <------ is this necessary?
xlength<-nrow(forest.dat)

for (i in 1:xlength)
      if (forest.dat$ID[x] == forest[ID[x] {print("Polygon OK")
        } else { Delele Polygon}

writeOGR(forest, ".", "ForestStandNew", "ESRI Shapefile")
~~~~~~~~~~~~~~~~~

The script above doesn't run because I don't know how to delete
polygons. Any ideas how to do this?


Thanks in advance.

Noli

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to