[R-sig-Geo] Shapefile Compatibility

Michael Sumner mdsumner at gmail.com
Mon Jul 25 05:04:30 CEST 2011


Ok, here's what I get - readShapePoly says it's an M-shapefile - as
there are 4 coordinate attributes, X, Y, Z, and M* on the vertices. I
would use rgdal if you can - OGR does not support the M coordinate but
it does Z, though these are discarded by readOGR. (They don't really
sensibly fit in any "flat" polygon data model but that's a long
story).

*  the fourth is not really a coordinate but a relative "Measure"
usually to store distance from a start point, but can be used to store
time (or other geometric dimension)

library(maptools)
 d <- readShapePoly("SSC_2011_AUST.shp")
Shapefile type: PolygonM (25), # of Shapes: 8529

Error in read.shape(filen = fn, verbose = verbose, repair = repair) :
  Shapefile type not (yet) handled by this function


Move to rgdal, this gives us useable 2D geometry data.

library(rgdal)

d <- readOGR(".", "SSC_2011_AUST")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "SSC_2011_AUST"
with 8529 features and 4 fields
Feature type: wkbPolygon with 3 dimensions
Warning messages:
1: In readOGR(".", "SSC_2011_AUST") :
  Dropping null geometries: 2627, 2628, 2629, 4174, 4175, 4176, 6036,
6037, 6884, 6885, 6886, 7774, 7775, 8196, 8197, 8198, 8415, 8416,
8520, 8521, 8522, 8528, 8529
2: In readOGR(".", "SSC_2011_AUST") : Z-dimension discarded


> sessionInfo()
R version 2.13.1 Patched (2011-07-09 r56344)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
   LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
  LC_TIME=English_Australia.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] rgdal_0.7-1     maptools_0.8-9  lattice_0.19-30 sp_0.9-83
foreign_0.8-44

loaded via a namespace (and not attached):
[1] grid_2.13.1  tools_2.13.1

On Mon, Jul 25, 2011 at 12:43 PM, Wang, Kevin (SYD)
<kevinwang at kpmg.com.au> wrote:
> Hi all,
>
> Apologies for the non-reproducible code.
>
> I've downloaded the following two files from the website:
>  * State Suburbs ASGS Non ABS Structures Ed 2011 Digital Boundaries in ESRI Shapefile Format
>  * Australian Drainage Divisions ASGS Non ABS Structures Ed 2011 Digital Boundaries in MapInfo ESRI Shapefile Format
>
> I then unzipped them into a folder and tried to read in:
>  * SSC_2011_AUST.shp
>  * ADD_2011_AUST.shp
> using the code I mentioned (separately, of course).
>
> sessionInfo() gave me:
>> sessionInfo()
> R version 2.13.0 (2011-04-13)
> Platform: i386-pc-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252
> [3] LC_MONETARY=English_Australia.1252 LC_NUMERIC=C
> [5] LC_TIME=English_Australia.1252
>
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils     methods   base
>
> other attached packages:
>  [1] rgdal_0.7-1     rgeos_0.1-8     stringr_0.5     gdata_2.8.2     classInt_0.1-14
>  [6] e1071_1.5-26    class_7.3-3     maptools_0.8-9  lattice_0.19-23 sp_0.9-83
> [11] foreign_0.8-43  gpclib_1.5-1    rcom_2.2-3.1    rscproxy_1.3-1
>
> loaded via a namespace (and not attached):
> [1] grid_2.13.0  gtools_2.6.2 plyr_1.5.2   tools_2.13.0
>
> Thanks!
>
> Kevin
>
>
>
>
>
> -----Original Message-----
> From: Michael Sumner [mailto:mdsumner at gmail.com]
> Sent: Monday, 25 July 2011 12:38 PM
> To: Wang, Kevin (SYD)
> Cc: r-sig-geo at r-project.org
> Subject: Re: [R-sig-Geo] Shapefile Compatibility
>
> As it stands, this is not reproducible code. Can you please replace the file.choose() calls with the path to the actual .shp file, then we could download the file and do the same. Also include full details of exactly which file you download.
>
> In case your R or packages are not up to date, please check that as well and provide us with your sessionInfo() details.
>
>
> Cheers, Mike.
>
> On Mon, Jul 25, 2011 at 12:17 PM, Wang, Kevin (SYD) <kevinwang at kpmg.com.au> wrote:
>> Hi all,
>>
>>
>>
>> It's probably a [silly] question that's more to do with "Shapefiles"
>> than R.
>>
>>
>>
>> I was just trying to read in a shape file from
>> http://www.abs.gov.au/AUSSTATS/abs@.nsf/DetailsPage/1270.0.55.003July%
>> 20
>> 2011?OpenDocument
>>
>>> Suburb10aAust.shp <- readShapePoly(file.choose(),
>> proj4string=CRS("+proj=longlat"))
>>
>> Shapefile type: PolygonM (25), # of Shapes: 8529
>>
>>
>>
>> Error in read.shape(filen = fn, verbose = verbose, repair = repair) :
>>
>>  Shapefile type not (yet) handled by this function
>>
>>
>>
>> I've also tried:
>>
>>> Suburb10aAust.shp <- readShapeSpatial(file.choose(),
>> proj4string=CRS("+proj=longlat"))
>>
>> Error in readShapeSpatial(file.choose(), proj4string =
>> CRS("+proj=longlat")) :
>>
>>  File type cannot be read
>>
>>
>>
>> Does this mean that the source file isn't a proper shapefile?
>>
>>
>>
>> Kind regards
>>
>>
>> Kevin Wang
>>
>> Manager, Government Advisory Services
>> Advisory
>>
>> KPMG
>> 10 Shelley Street
>> Sydney  NSW  2000  Australia
>>
>>
>>
>> Tel
>>
>>        +61 2 9335 8282
>>
>> Fax
>>
>>        +61 2 9335 7001
>>
>> Mob
>>
>>        0419 374 580
>>
>> kevinwang at kpmg.com.au <mailto:kevinwang at kpmg.com.au>
>>
>>
>>
>> kpmg.com.au <http://kpmg.com.au>
>>
>>
>>
>> Protect the environment: please think before you print
>>
>>
>>
>>
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
>
>
> --
> Michael Sumner
> Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia
> e-mail: mdsumner at gmail.com
>
> ******************************************************************
>
> The information in this e-mail is confidential and may be legally
> privileged. It is intended solely for the addressee. Access to this
> e-mail by anyone else is unauthorised. If you have received this
> communication in error, please notify us immediately by return
> e-mail with the subject heading "Received in error" or telephone
> +61 2 93357000, then delete the email and destroy any copies of it.
> If you are not the intended recipient, any disclosure, copying,
> distribution or any action taken or omitted to be taken in reliance
> on it, is prohibited and may be unlawful. Any opinions or advice
> contained in this e-mail are subject to the terms and conditions
> expressed in the governing KPMG client engagement letter. Opinions,
> conclusions and other information in this e-mail and any
> attachments that do not relate to the official business of the firm
> are neither given nor endorsed by it.
>
> KPMG cannot guarantee that e-mail communications are secure or
> error-free, as information could be intercepted, corrupted,
> amended, lost, destroyed, arrive late or incomplete, or contain
> viruses.
>
> KPMG, an Australian partnership and a member firm of the KPMG
> network of independent member firms affiliated with KPMG
> International Cooperative (“KPMG International”), a Swiss entity.
> KPMG International provides no services to clients.
>
> Liability limited by a scheme approved under Professional Standards
> Legislation.
>
> ******************************************************************



-- 
Michael Sumner
Institute for Marine and Antarctic Studies, University of Tasmania
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list