On Wed, 28 Feb 2007, Barbara Diane-Spillmann wrote:
> dear all,
>
> i?m trying to plot a map of population density in german communities by
> using shape files.
> to plot the polygons is not the problem but as soon as I want to add the
> population data to the map I get the following message:
>
> Fehler in if (attr(theMap$Shapes[[ii]], "nParts") == 1) { :
> Argument hat L?nge 0
>
> My population data are either in form of a csv file or a column of the
> dbf file. either possibility gives me the message above.
> what does R want to tell me?
I assume that you are using read.shape() from the maptools package,
followed by plot.Map(), a deprecated function from the same package. It is
possible that you also have a poorly written command, which you have not
shown. If your second argument was not named explicitly, and is assumed to
be recs, mahem may break loose (and has here - function most likely
looking for out-of-range geometries indexed by population numbers).
The currently recommended approach is to read your shapefile into an
object specifically designed to keep the geometries and their attribute
data correctly associated. The function readShapePoly() in maptools will
do this. The plot method for the object you read will by default only show
the boundaries, but if you are willing to use lattice graphics, you can
get there in two lines:
x <- readShapePoly(<my_file.shp>)
spplot(x, "chosen_column_name")
for variable "chosen_column_name" in the shapefile DBF.
You can also use base graphics, but then need to pass a vector of colours
through the col= argument, usually by look-up in a short vector of colours
indexed by findInterval() on the variable of interest.
Please consider posting follow-ups to the R-sig-geo list, which is more
focussed.
>
> thank you for your help
>
> barbara
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
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