Skip to content

error in readShapePoly

4 messages · Roger Bivand, Hurlbert, Allen H. (Biology)

#
Thanks Roger!

Are there any instances in which one would want delete_null_obj=FALSE?

-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand at nhh.no] 
Sent: Wednesday, June 10, 2009 10:36 AM
To: Hurlbert, Allen H. (Biology)
Subject: RE: [R-sig-Geo] error in readShapePoly
On Wed, 10 Jun 2009, Hurlbert, Allen H. (Biology) wrote:

            
proj4string,
=
readShapePoly(paste("\\\\Bioark.bio.unc.edu\\hurlbertallen\\GIS\\BirdRan
file
file
It is a bit more revealing:
Error in ogrInfo(dsn = dsn, layer = layer, input_field_name_encoding = 
input_field_name_encoding) :
   NULL geometry found

and suggests using the fix in:
+  delete_null_obj=TRUE)
Warning message:
In .Map2PolyDF(Map, IDs = IDvar, proj4string = proj4string, force_ring =

force_ring,  :
   Null objects with the following indices deleted: 134

So the data provider has inserted a NULL geometry into the data - they 
shouldn't do it, but it has been seen before. Could you summarise to the

list, please? I'll see if I can add a test in readShapePoly to point
users 
to the optional argument.

Roger
for
where,
others
an
but

  
    
#
On Wed, 10 Jun 2009, Hurlbert, Allen H. (Biology) wrote:

            
Well, they shouldn't be there, really. When I release maptools, with 
default delete_null_obj=FALSE, it will report which one, and then:

library(foreign)
tip <- read.dbf("trin_inca_pl.dbf")
tip[134,]

would show the contents of the DBF for the offending NULL geometry. 
Setting it to TRUE by default wouldn't warn the user that there was 
anything untoward. In this case, the file originator might want to know 
that a geometry has gone away, perhaps. In an earlier case, Statistics 
Australia was squirrelling data with no spatial position away in a NULL 
geometry, which is OK for the DBF, but not OK if the files are (as they 
are) intended to contain geometries with attributes.

Roger

  
    
#
Is there an equivalent argument in readOGR() to read in a shapefile with
a NULL geometry, or can this only be done with readShapePoly?

Thanks,
Allen

-----Original Message-----
From: Roger Bivand [mailto:Roger.Bivand at nhh.no] 
Sent: Wednesday, June 10, 2009 12:44 PM
To: Hurlbert, Allen H. (Biology)
Cc: r-sig-geo at stat.math.ethz.ch
Subject: RE: [R-sig-Geo] error in readShapePoly
On Wed, 10 Jun 2009, Hurlbert, Allen H. (Biology) wrote:

            
Well, they shouldn't be there, really. When I release maptools, with 
default delete_null_obj=FALSE, it will report which one, and then:

library(foreign)
tip <- read.dbf("trin_inca_pl.dbf")
tip[134,]

would show the contents of the DBF for the offending NULL geometry. 
Setting it to TRUE by default wouldn't warn the user that there was 
anything untoward. In this case, the file originator might want to know 
that a geometry has gone away, perhaps. In an earlier case, Statistics 
Australia was squirrelling data with no spatial position away in a NULL 
geometry, which is OK for the DBF, but not OK if the files are (as they 
are) intended to contain geometries with attributes.

Roger
force_ring
readShapePoly(paste("\\\\Bioark.bio.unc.edu\\hurlbertallen\\GIS\\BirdRan
=
the
up
all

  
    
#
On Wed, 10 Jun 2009, Hurlbert, Allen H. (Biology) wrote:

            
No, readOGR() uses drivers for multiple vector formats, and as it is now 
written, it stops when a NULL geometry is found. This isn't likely to 
change very soon, but will go on the TODO list.

Roger