[R-sig-Geo] Extracting "lines" from ArcGIS file

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Jan 28 15:42:36 CET 2011


On Fri, Jan 28, 2011 at 1:03 PM, Christian Paroissin
<christian.paroissin at univ-pau.fr> wrote:
> Hello,
>
> I have downloaded an Arcgis file here:
> http://services.sandre.eaufrance.fr/data/zonage/Hydrographie2010/arcgis/Bassins/AG/COURS_D_EAU.SHP.zip
>
> I would like to extract informations from these dataset. It gives an S4
> object but I know nothing about it. Here is the code I wrote:
>
> [code]
> object1.shp <- readShapeSpatial("Cours-AG/COURS_D_EAU.shp")
> index= which(object1.shp$TOPONYME=="L'Adour")
> object1.shp[index,]
> [/code]
>
> I would like to extract the 'information' called "lines" but I don't known
> how do it. I find how to extract the 'information' "bbox"
> [quote]
> object1.shp[index,]@bbox
> object1.shp[index,]@lines
> [/quote]
>
> Could you help me please?
>
> Do "lines" correspond to the coordinates of the different points defining
> the river ("L'Adour" in my case)?

 Yes. but rivers are never simple. The data structure is therefore complex :)

 object1.shp is a SpatialLinesDataFrame. Its a bit like a dataframe,
but with a geometry for each row. Each row is a 'feature' - not
necessarily a single wiggly line, it could be several lines. In your
case it seems there is one of everything, so you can do:

object1.shp[index,]@lines[[1]]@Lines[[1]]@coords

to get a 2-column matrix of the coordinates of that feature.

See the help for SpatialLinesDataFrame and the vignette for the sp
package and the ASDAR book for more.

Barry



More information about the R-sig-Geo mailing list