Hi, 

thanks for the hint, but to start from "scratch". After loading the data
with readOGR:

> mask=readOGR("./", "mask_a")
> river=readOGR("./", "Zerafshan_river_network")
> dem_ascii=readGDAL("./zerafshan_mod_dem.asc")


> class(mask)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"

spplot(mask) yields the desired results, a hole in the middle. 

Then I went for the overlay, two ways:
1) sp.layout

mask_lay=list("sp.polygons", mask, col="black", fill="red")
river_lay=list("sp.lines", river, fill="blue")

plot_dem=spplot(dem_ascii, col.regions=terrain.colors(400),
sp.layout=list(river_lay, mask_lay)) 

print(plot_dem)

the plot shows the DEM and the river network

2) with the panel function

map.panel=function(...) 
{
        panel.gridplot(...)
        sp.polygons(mask, fill=c"red")
        sp.lines(river, col="red")
}

plot_dem=spplot(dem_ascii, col.regions=terrain.colors(400),
panel=map.panel)
print(plot_dem)

I get a totally red plot. 

if I go for checkPolygonsHoles:

>test=checkPolygonsHoles(mask)
Error in checkPolygonsGEOS(x, properly = properly, useSTRtree =
useSTRtree) : 
  not a Polygons object

> is(mask)
[1] "SpatialPolygonsDataFrame" "SpatialPolygons"         
[3] "Spatial"                  "SpatialPolygonsNULL"     


Maybe I did not understand the classes and object syntax right by know,
but I don't see what is wrong.


Thanks for the time!

Stefan




On Fri, 2012-09-21 at 16:41 +0200, Mathieu Rajerison wrote:

> Hi,
> 
> I don't know if it's going to solve your problem but have you tried to
> run maptools::checkPolygonsHoles
> 
> http://hosho.ees.hokudai.ac.jp/~kubo/Rdoc/library/maptools/html/checkPolygonsHoles.html
> 
> Mat
> 
> 2012/9/20 sluedtke <sluedtke@gfz-potsdam.de>
> 
>         Dear friends,
>         
>         
>         am trying to overlay a polygon data set as a
>         SpatialPolygonDateFrame to
>         an existing plot. The data set has a hole in the middle, and I
>         do not
>         want to have any filling in there. If a check the shape in a
>         GIS,
>         everything looks fine, but using the following commands to do
>         the plot,
>         the hole is filled.
>         
>         That is the code I am using, the data is attached. Thanks in
>         advance!
>         
>         Stefan
>         
>         
>         
>         ################################################################################################
>         
>         library(sp)
>         library(rgdal)
>         library(raster)
>         library(latticeExtra)
>         
>         
>         ###############################################################################################
>         #read the DEM from the ASCII format
>         
>         dem_ascii=raster(readGDAL("./zerafshan_mod_dem.asc"))
>         
>         
>         ###############################################################################################
>         # read additional data for printing
>         mask=readOGR("./", "mask_zerafshan")
>         
>         ###############################################################################################
>         
>         #plot this stuff
>         plot_dem=spplot(dem_ascii, col.regions=terrain.colors(400),
>         colorkey=list(width=1, space="right"))+
>         layer(sp.polygons(mask,fill="lightgray"))
>         
>         print(plot_dem)
>         ################################################################################################
>         
>         
>         
>         mask_zerafshan.dbf (110 bytes)
>         <http://r-sig-geo.2731867.n2.nabble.com/attachment/7580992/0/mask_zerafshan.dbf>
>         mask_zerafshan.prj (143 bytes)
>         <http://r-sig-geo.2731867.n2.nabble.com/attachment/7580992/1/mask_zerafshan.prj>
>         mask_zerafshan.shp (173K)
>         <http://r-sig-geo.2731867.n2.nabble.com/attachment/7580992/2/mask_zerafshan.shp>
>         mask_zerafshan.shx (150 bytes)
>         <http://r-sig-geo.2731867.n2.nabble.com/attachment/7580992/3/mask_zerafshan.shx>
>         zerafshan_mod_dem.asc (1M)
>         <http://r-sig-geo.2731867.n2.nabble.com/attachment/7580992/4/zerafshan_mod_dem.asc>
>         
>         
>         
>         
>         --
>         View this message in context:
>         http://r-sig-geo.2731867.n2.nabble.com/plotting-holes-of-esri-shape-files-tp7580992.html
>         Sent from the R-sig-geo mailing list archive at Nabble.com.
>         
>         _______________________________________________
>         R-sig-Geo mailing list
>         R-sig-Geo@r-project.org
>         https://stat.ethz.ch/mailman/listinfo/r-sig-geo 
> 
> 

	[[alternative HTML version deleted]]

