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

Edzer Pebesma edzer.pebesma at uni-muenster.de
Mon Jan 31 09:21:10 CET 2011



On 01/28/2011 03:42 PM, Barry Rowlingson wrote:
> 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.

What will also work is:

coordinates(object1.shp[index,])[[1]][[1]]

> 
> See the help for SpatialLinesDataFrame and the vignette for the sp
> package and the ASDAR book for more.
> 
> Barry
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list