[R-sig-Geo] Res: Subsetting shapefile type PolyLine
Roger Bivand
Roger.Bivand at nhh.no
Mon Feb 4 18:26:18 CET 2008
On Mon, 4 Feb 2008, Rafael Duarte wrote:
> Obrigado Milton.
>
> But:
> teste2[teste2$ELEVATION == 100]
>
> gives me an empty list. And I have data of Elevation = 100.
>
> I also tried
> teste2[teste2$ELEVATION >= 100]
>
> teste2[teste2$ELEVATION == "100"]
>
> But always an empty list and no plot.
>
Very close, with:
getinfo.shape("bat_lin")
teste2 <- readShapeLines("bat_lin")
names(teste2)
should show ELEVATION - then the help should also work. I think that the
original teste2 would say that its class() was "Map" - for the selection
with [ to work, it should be a SpatialLinesDataFrame.
read.shape is part of the infrastructure, and users are really advised to
move to sp classes, and either readShape*(), or (even better) readOGR() in
the rgdal package, for which you don't need to know in advance what kind
of shapefile you are reading.
Hope this helps,
Roger
>
>
> Milton Cezar Ribeiro wrote:
>
>> Hi Rafael
>> i think that it could help you
>> teste2.elev100<-teste2[teste2$ELEVATION=100]
>> plot(teste2,axes=T)
>> plot(teste2.elev100,col=2,add=T)
>> Boa sorte.
>> Miltinho
>> Brazil
>> ----- Mensagem original ----
>> De: Rafael Duarte <rduarte at ipimar.pt>
>> Para: r-sig-geo at stat.math.ethz.ch
>> Enviadas: Segunda-feira, 4 de Fevereiro de 2008 8:23:08
>> Assunto: [R-sig-Geo] Subsetting shapefile type PolyLine
>>
>> Dear all,
>>
>> I am very new to SIG.
>> This is probably a very simple question but I could not find an answer
>> searching the web and the R-SIG emails archive.
>>
>> I have an ESRI shapefile with a coast and bathymetric lines. In the dbf
>> file I have a column ?ELEVATION? that gives this information.
>>
>> I import the shapefile with:
>>
>> require(maptools)
>> teste2 <- read.shape("bat_lin")
>> Shapefile type: PolyLine, (3), # of Shapes: 981
>>
>> Now I plot this information:
>> plot(teste2)
>>
>> But my problem is that I want to plot a subset of bathymetric lines:
>> ELEVATION = 100, for example.
>>
>> I tried to follow the example given in maptools: subset.
>> I tried to use functions: Map2lines.
>> But I could not find a solution to plot only a subset of bathymetric
>> lines.
>>
>> Many thanks for any help.
>>
>> Rafael
>>
>>
>> --
>> Rafael Duarte
>> Marine Resources Department - DRM
>> IPIMAR - National Research Institute for Agriculture and Fisheries
>> Av. Brasília, 1449-006 Lisbon - Portugal
>> Tel:+351 21 302 7000 Fax:+351 21 301 5948
>> e-mail: rduarte at ipimar.pt <mailto:rduarte at ipimar.pt>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch <mailto:R-sig-Geo at stat.math.ethz.ch>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>>
>> ------------------------------------------------------------------------
>> Abra sua conta no Yahoo! Mail
>> <http://br.rd.yahoo.com/mail/taglines/mail/*http://br.mail.yahoo.com/>,
>> o único sem limite de espaço para armazenamento!
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list