Thanks a lot for your precious help, it worked perfectly. Most probably,
the first errors arose from importing a shapefile where I merged some
counties using MapViewer - perhaps the newly created shapefile was a bit
messy. 

However, I now have the problem that I have to repeat the merging of 100
out of the 440 counties using R. But I'll better put the question 
in a new thread.

Katharina


-----Original Message-----
From: Roger Bivand [mailto:[EMAIL PROTECTED] 
Sent: Mittwoch, 8. November 2006 18:05
To: Frosch, Katharina
Cc: r-sig-geo@stat.math.ethz.ch
Subject: Re: readOGR() - choice of layer in MIF/MID file?

On Wed, 8 Nov 2006, Frosch, Katharina wrote:

> Hello all,
> 
> [this is the continuation of a thread originally posted to r-help]
> 
> As recommended by Roger, I installed the rgdal package and went
through
> the description of my MIF/MID files. However, I was not able to load
the
> data using readOGR(), most probably because I did not manage to
> correctly specify the layer. As I am pretty new to spatial data
analysis
> and R, I am still a bit lost. 
> 
> I tried with 
> setwd("E\\Maps\\MIF")
> test<-readOGR("testmif.mif", layer = "layer1")
> 

Could you try:

test<-readOGR("testmif.mif", layer = "testmif")

treating the data source name as the file and the layer as the file name

without extensions?

Roger

> and got the error message "Error in ogrInfo(dsn = dsn, layer = layer:
> Cannot open layer"
> 
> testmif.MIF
> testmif.MID
> containing "points", "polygons" and "regions" and corresponding
> attribute data. 
> (R version 2.4.0 on Windows XP)
> 
> How to find out the correct layer name? The description file of the
> MIF/MID file contains only descriptions of the attributes and
elements,
> but no explicit layer names. 
> 
> Katharina
> 
> ****************************+
> 
> Katharina Frosch
> Rostocker Zentrum
> Konrad-Zuse-Str. 1
> 18057 Rostock
> Tel.: (0381) 2081-148
> Fax: (0381) 2081-448
> Mail: [EMAIL PROTECTED] 
> 
> 
> 
> 
> -----Original Message-----
> From: Roger Bivand [mailto:[EMAIL PROTECTED] 
> Sent: Dienstag, 7. November 2006 20:47
> To: Frosch, Katharina
> Cc: r-help@stat.math.ethz.ch
> Subject: RE: [R] wrong fill colors in polygon-map
> 
> On Tue, 7 Nov 2006, Frosch, Katharina wrote:
> 
> > Dear Roger: Thank you for your help and the hint with the R-sig-geo
> list
> > (next time I'll post directly to it)!
> > 
> > I went again through all points you mentioned: 
> > - polygons and rows of data are in the same order
> > - the number of polygons and data rows is identical
> > - I experimented with different values, and also defined explicit
> > breakpoints without using the quantile (no effect)
> > - then I added all.inside=TRUE in findIntervall (no effect)
> > 
> > However, adding the forcefill=FALSE option to the plot command led
to
> a
> > strange effect: three districts were left blank. Two of these
> districts
> > were districts that are situated around another district (district
> > A=city itself, district B=the countryside around). The third
> problematic
> > district is situated close to the Swiss border and next to a big
lake.
> I
> > deleted the three districts, to see what happens. The problem is
> partly
> > resolved, but new blank districts appear. 
> > 
> > Could this be caused by a corrupted shape file rathern than by R? I
> > loaded the shape-file with the Program Mapviewer in MIF/MID format,
> > unionized some districts, then exported it to an ESRI-shapefile and
> used
> > it in R. 
> 
> It is at least worth trying. May I suggest reading the MIF/MID file
> directly into R using the readOGR() function in the rgdal package? If
> you
> are a Mac OSX user, there is extra help needed installing rgdal, but
on
> Windows it is available for binary install directly from CRAN (thanks
to
> Uwe Ligges). The spatial classes used there are more robust, and the
> data
> and polygons can be kept together. Polygons may also be dissolved
using
> objects of the SpatialPolygons class.
> 
> Could I suggest that you move any reply to R-sig-geo, given that the 
> details of spatial data formats are not of general interest?
> 
> Roger
> 
> > 
> > I don't have any clue to resolve this...so any hint is very welcome!
> > Katharina
> > 
> > 
> > 
> > **************************
> > Katharina Frosch
> > Rostocker Zentrum
> > Konrad-Zuse-Str. 1
> > 18057 Rostock
> > Tel.: (0381) 2081-148
> > Fax: (0381) 2081-448
> > Mail: [EMAIL PROTECTED] 
> > 
> >  
> > 
> > 
> > -----Original Message-----
> > From: Roger Bivand [mailto:[EMAIL PROTECTED] 
> > Sent: Dienstag, 7. November 2006 13:27
> > To: Frosch, Katharina
> > Cc: r-help@stat.math.ethz.ch
> > Subject: Re: [R] wrong fill colors in polygon-map
> > 
> > On Tue, 7 Nov 2006, Frosch, Katharina wrote:
> > 
> > > Dear all,
> > > 
> > > I would like to produce a map with information about the patenting
> > > activity in German districts, by coloring districts with different
> > > degrees of patenting activity in different colors. I work with the
> > > packages maptools, maps and spdep. The map data is read from an
> > external
> > > .shp file (+ the corresponding .shx and .dbf files). Plotting a
map
> > with
> > > the IDs or the patenting indicator itself works fine. But coloring
> the
> > > map leads to completely odd results (wrong colors for most of the
> > > regions). I also tried simpler values (just 0 and 1 for different
> > > regions), same problem. I tried to check whether there is any
> problem
> > > with the match of data and district ids, but everything seemed to
be
> > > fine. 
> > > 
> > > Sample code: 
> > > ****************
> > > brks.pat<-quantile(patenting$patbus)
> > > #palette.pat<-c("green", "blue", "grey", "darkgrey", "red")
> > > palette.pat<-c(rep("green", 4), "red")
> > > plot(iab7.poly, col=palette.pat[findInterval(patenting$patbus,
> > > brks.pat)])
> > > legend(1200, -200, fill=palette.pat, legend=round(brks.pat,2),
> > cex=0.6)
> > > title(main="patenting activity in german districts")
> > > 
> > > Data:
> > > ******
> > > Iab7.poly contains the polygons of 343 German districts
> > > patenting$patbus contains the number of corporate patents per
> 100.000
> > > inhabitants for each district
> > 
> > (R-sig-geo may be a more focussed list for this kind of question)
> > 
> > If the polygons in Iab7.poly are in the same order as the rows of
> > patenting, and the number of polygons is the same as the number of
> rows,
> > it is possible that the breakpoints are not quite what you think (if
> for
> > example some of the quantiles are equal, which happens with
> > zero-inflated
> > data). Omitting all.inside=TRUE in findInterval() can also lead to
the
> > insertion of NA values into the vector of colours.
> > 
> > Perhaps have a look at the classInt package for some examples of
> > choosing 
> > class intervals i.a. for map display.
> > 
> > Roger
> > 
> > > 
> > > Any ideas would be appreciated!
> > > 
> > > Best regards,
> > > Katharina
> > > 
> > > 
> > > 
> > > ******************************
> > > 
> > > Katharina Frosch
> > > Rostock Center for the Study of Demographic Change
> > > Konrad-Zuse-Str. 1
> > > 18057 Rostock
> > > Tel.: (0381) 2081-148
> > > Fax: (0381) 2081-448
> > > Mail: [EMAIL PROTECTED] 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > ----------
> > > This mail has been sent through the MPI for Demographic
> > Rese...{{dropped}}
> > > 
> > > ______________________________________________
> > > R-help@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: [EMAIL PROTECTED]


----------
This mail has been sent through the MPI for Demographic Rese...{{dropped}}

_______________________________________________
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