[R-sig-Geo] Re: R-sig-Geo Digest, Vol 6, Issue 8

Nicholas Lewin-Koh nikko at hailmail.net
Sun Feb 29 13:22:54 CET 2004

In maptools I had some exerimental code for writing shape files and dbf
I know the c code is still there in the distribution (from shapelib) 
and i think the C-R-api wrapper is still there. 
I can look later and see if I can get the functions working again
since Roger took it over. Luckily Roger is better than me about
commenting code.


On Sun, 29 Feb 2004 12:04:45 +0100 (MET),
r-sig-geo-request at stat.math.ethz.ch said:
> Send R-sig-Geo mailing list submissions to
> 	r-sig-geo at stat.math.ethz.ch
> To subscribe or unsubscribe via the World Wide Web, visit
> 	https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo
> or, via email, send a message with subject or body 'help' to
> 	r-sig-geo-request at stat.math.ethz.ch
> You can reach the person managing the list at
> 	r-sig-geo-owner at stat.math.ethz.ch
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-sig-Geo digest..."
> Today's Topics:
>    1. Re: [R] writing polygons/segments to shapefiles (.shp) or
>       other   ArcGIS compatible file (Paul Murrell)
> ----------------------------------------------------------------------
> Message: 1
> Date: Sun, 29 Feb 2004 10:28:16 +1300
> From: Paul Murrell <p.murrell at auckland.ac.nz>
> Subject: [R-sig-Geo] Re: [R] writing polygons/segments to shapefiles
> 	(.shp) or other	ArcGIS compatible file
> To: Patrick Giraudoux <patrick.giraudoux at univ-fcomte.fr>
> Cc: r-sig-geo at stat.math.ethz.ch, r-help at stat.math.ethz.ch,
> 	Benjamin.STABLER at odot.state.or.us,	Florian Tolle
> 	<florian.tolle at univ-fcomte.fr>,	Francis Raoul
> 	<francis.raoul at univ-fcomte.fr>
> Message-ID: <404107F0.2010903 at stat.auckland.ac.nz>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> Hi
> Patrick Giraudoux wrote:
> > Hi,
> > 
> > Thanks for all those information and the most valuable library you have developed.
> > 
> > If somebody is to develop something to write shapefiles from polygon coordinates within R (most welcome), I don't think that the
> > attribute file (dbf) will be an important issue. If we have got an output with the index to link the dbf records to each shape of a
> > shapefile, any text file can be handled in R or Excel to create a dbf. The real issue is the encoding of the *.shp and *.shx  etc..
> > (and an index file for the dbf)
> > 
> > Most important is to consider that ESRI has stopped developping ArcView and AVENUE. They have moved to ArGIS and Visual Basic. In
> > this new generation framework, importation is managed with ArcToolBox which, to my knowledge, is very limited considering
> > importation of text objects (actually I even wonder if one can import something but attribute tables without ArcInfo). For instance,
> > the way I found to solve the problem I met was to write a programme in R to wrap the polygon coordinates in a text file readable in
> > GRASS (an opensource GIS), to import it into GRASS and to export the shapefile from GRASS. This shapefile was finally imported to
> > ArcGIS.  I would not insist on ESRI client policy. I just want to say that the more I know corporates the more I love opensource...
> > 
> > Anyway, there are many things that can be made in R which may deserve not only importation to R, but also exportation to many kinds
> > of GIS. To write shapefiles from polygon, points or lines created in R would be most useful.
> I don't know anything about shapefiles, but that's starting to sound 
> like a "shapefile" graphics device (c.f. the gtkDevice, RSvgDevice 
> packages).
> Paul
> > Many thanks for your interest and support,
> > 
> > Patrick Giraudoux
> > 
> > 
> > Université de Franche-Comté
> > Laboratoire de Biologie environnementale
> > EA3184 usc INRA
> > F-25030 Besançon Cedex
> > 
> > tél.: +33 381 665 745
> > fax.: +33 381 665 797
> > http://lbe.univ-fcomte.fr
> > 
> > "Ce n'est pas en améliorant la bougie que l'on a inventé l'électricité", la recherche fondamentale est indispensable !
> > 
> > 
> > 
> > 
> > ----- Original Message ----- 
> > From: <Benjamin.STABLER at odot.state.or.us>
> > To: <patrick.giraudoux at univ-fcomte.fr>
> > Cc: <r-help at stat.math.ethz.ch>; <r-sig-geo at stat.math.ethz.ch>
> > Sent: Thursday, February 26, 2004 7:11 PM
> > Subject: Re: [R] writing polygons/segments to shapefiles (.shp) or other ArcGIS compatible file
> > 
> > 
> > 
> >>The main limitation of the shapefiles package that I put together is that it
> >>does not create shapefiles from R objects - rather it only writes shapefiles
> >>that have been read into R and manipulated within the constraints of the
> >>existing file structure.  By this I mean that for example you can change the
> >>coordinates of points and write them back out.  Or you can add a bunch of
> >>blank columns in the DBF outside of R and then fill them in with R.  But I
> >>did not write any code to calculate byte offsets and such and that are
> >>needed when creating a shapefile from scratch.
> >>
> >>So what I do when I want to create a new shapefile from within R is write
> >>out the format required by the ASCII Tool ArcView (Avenue) script.  This
> >>script is available at: http://arcscripts.esri.com/details.asp?dbid=11442
> >>The format is simple:
> >>
> >>Works for space delimited ascii to point, polygon and polyline. The format
> >>for point ascii file is id, x, y (no comma for real data, space delimited).
> >>For polygon & polyline ascii files, the format is code (1 for start point, 2
> >>for middle points, 3 for end point), x, y (no comma for real data, space
> >>delimited). Export shapefile to ascii file works for point, polyline and
> >>polygon shapefiles. The output format file is id, x, y. For polygon and
> >>polyline, the id is the sequence id of vertices.
> >>
> >>Thus all you have to do is write a text file, install the script in ArcView
> >>and then use the ArcView extension to create a shapefile from the ASCII
> >>file.  Unfortunately ASCII tool only works with the geography - you have to
> >>add the attributes later.
> >>
> >>With all of that said, I would like to add to the shapefiles package the
> >>ability to write out shapefiles from scratch.  Since the shapefiles format
> >>is rather unique, I think it would be best to use the maptools ShapeList/Map
> >>class format (or r-spatial's classes).  For starters the package would just
> >>write out the geography (like the ASCII tool Avenue script).  Later would be
> >>added the ability to write the dbf data out from the att.data element of the
> >>Map object.
> >>
> >>Unfortunately I don't know when I will have the time to do this.  If anyone
> >>else wants to do then please go ahead and I can help via email if needed.
> >>But adding the ability to write out shapefiles from scratch is on my list.
> >>Once I finish coding our travel demand model and we enter the application
> >>phase (probably in a few months) then will our demand to output shapefiles
> >>from R increase and I can justify spending the time to write the code.
> >>
> >>I apologize that I have not paid much attention to the r-sig-geo discussion
> >>or Edzer's r-spatial project.  If there is an effort underway to write out
> >>shapefiles then can someone please inform me of its status.  If not, then
> >>maybe I can help.  Thanks.
> >>
> >>Benjamin Stabler
> >>Transportation Planning Analysis Unit
> >>Oregon Department of Transportation
> >>555 13th Street NE, Suite 2
> >>Salem, OR 97301  Ph: 503-986-4104
> > 
> > 
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> -- 
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> paul at stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/
> ------------------------------
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://www.stat.math.ethz.ch/mailman/listinfo/r-sig-geo
> End of R-sig-Geo Digest, Vol 6, Issue 8
> ***************************************

More information about the R-sig-Geo mailing list