[R] Arc/Info Ungenerate - shp - Maps

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Jun 3 15:50:17 CEST 2009


On Wed, Jun 3, 2009 at 1:17 PM, Rodrigo Aluizio <r.aluizio at gmail.com> wrote:
> Hi list.
>
> I would like to know if someone had already successfully loaded and Arc/Info
> Ungenerated (.dat – extracted from
> http://rimmer.ngdc.noaa.gov/mgg/coast/getcoast.html) file on R. I’m able to
> do so with shape files using maptools functions, but these ungenerated data
> are making me crazy.
>
> I don’t have any of ArcGIS tools (one of them probably can do that), and I
> can’t find any free tool that converts these .dat (lat, long coordinates) to
> .shp.

 If you look at the ungenerate format files you'll see that they are plain text:

1
 -17.999932,27.647185
 -18.000812,27.646891
 -18.002572,27.648651
 -18.003452,27.648651
 -18.004332,27.647771

 etc etc until

END
2
 [more coord pairs]
END

etc etc until

END
END

 So you could read these in with 'scan' or 'read.table', and then
manipulate them in order to feed to the sp routines for constructing
Spatial Line or Polygon objects. See Bivand,Pebesma and Gomez-Rubio's
Applied Spatial Data Analysis in R book for details. Once you've
written a nice function to do that, tell us and maybe it'll go into a
package somewhere.

[ An easy trick would be to open the file in a text editor, and
replace any line that didn't have a comma with NA,NA: then you could
read the whole thing using read.csv, and then use plot(...,type='l')
to display the features. The NA,NA coords act as a break to produce
separate polygons or line segments ]

 You might also like to ask on the R-sig-geo group. Probably more
appropriate mailing list than this one.

Barry




More information about the R-help mailing list