[R-sig-Geo] Creating new neighbour's list for aggregated regions and writing to shapefile
Roger Bivand
Roger.Bivand at nhh.no
Sun Sep 28 15:14:42 CEST 2008
On Sat, 27 Sep 2008, Roberto Patuelli wrote:
> Hi All,
>
> I want to aggregate my NUTS-3 regions in bigger ones, for which, of
> course, I have corresponding codes. I have two main problems:
>
> 1) In terms of map visualization, I used unionSpatialPolygons(),
> starting from my original shape file. At this point I would like to
> write the resulting object out to a shape file by writePolyShape(),
> but R gives me the following answer: class(x) ==
> "SpatialPolygonsDataFrame" is not TRUE
You have created a new SpatialPolygons object, say x, but shapefiles also
need attribute data. As an absolute minimum, do
IDs <- sapply(slot(x, "polygons"), function(i) slot(i, "ID"))
# to retrieve the new IDs
df <- data.frame(y=rep(1, length(IDs)), row.names=IDs)
xx <- SpatialPolygonsDataFrame(x, data=df)
writePolyShape(xx, "filename")
>
> 2) In order to use spatial econometric techniques, I need to obtain a
> new neighbours list. Because of islands problems that have already
> been solved, rather than creating a new spatial weights matrix, I
> would like to obtain this by aggregating the one based on the
> original regions, or by aggregating directly the neighbour's set (a
> listw object for example), if possible.
This looks like a new function for spdep, somewhat like the reverse of
nb2blocknb(). If you could provide me with an example off-list, I'll see
what can be done.
Roger
>
> Can anyone help on these two problems?
>
> Thanks and best regards,
> Roberto Patuelli
>
>
>
> ********************
> Roberto Patuelli, Ph.D.
> Post-doc researcher
> Institute for Economic Research (IRE)
> University of Lugano (USI)
> via Maderno 24, CP 4361
> CH-6904 Lugano
> Switzerland
> Phone: +41-(0)58-666-4166
> Email: roberto.patuelli at lu.unisi.ch
> ********************
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at 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.Bivand at nhh.no
More information about the R-sig-Geo
mailing list