[R-br] RES: RES: Criar um novo shapefile à partir da seleção de áreas no shapefile original [RESOLVIDO]

ASANTOS alexandresantosbr em yahoo.com.br
Terça Agosto 25 01:00:34 BRT 2015


Mauro,

     Você precisa mudar o nome 'POLY' ou apagar os arquivos criados, 
pois a função writeOGR() não sobrescreve um arquivo criado,

Abraço,


-- 
======================================================================
Alexandre dos Santos
Proteção Florestal
IFMT - Instituto Federal de Educação, Ciência e Tecnologia de Mato Grosso
Campus Cáceres
Caixa Postal 244
Avenida dos Ramires, s/n
Bairro: Distrito Industrial
Cáceres - MT                      CEP: 78.200-000
Fone: (+55) 65 8132-8112 (TIM)   (+55) 65 9686-6970 (VIVO)
e-mails:alexandresantosbr em yahoo.com.br
         alexandre.santos em cas.ifmt.edu.br
Lattes: http://lattes.cnpq.br/1360403201088680
======================================================================




Em 24/08/2015 22:26, Mauro Sznelwar escreveu:
> Me deu este problema aqui quando rodei.
>
>> writeOGR(srdf, getwd(), 'POLY', 'ESRI Shapefile')
> Error in writeOGR(srdf, getwd(), "POLY", "ESRI Shapefile") :
>    layer exists, use a new layer name
>
> Onde eu abro arquivos de formato shp e shx?
>
> S
>
>
> egue CRM final:
>
> #Pacotes
> require(shapefiles)
> require(rgdal)
> require(maptools)
> #---------------------------------------------------------------------------
> ----
> #Criação de 4 polígonos
> sr1=Polygons(list(Polygon(cbind(c(180114, 180553, 181127, 181477,
> 181294, 181007, 180409,
>     180162, 180114), c(332349, 332057, 332342, 333250, 333558, 333676,
>     332618, 332413, 332349)))),'1')
> sr2=Polygons(list(Polygon(cbind(c(180042, 180545, 180553, 180314,
> 179955, 179142, 179437,
>     179524, 179979, 180042), c(332373, 332026, 331426, 330889, 330683,
>     331133, 331623, 332152, 332357, 332373)))),'2')
> sr3=Polygons(list(Polygon(cbind(c(179110, 179907, 180433, 180712,
> 180752, 180329, 179875,
>     179668, 179572, 179269, 178879, 178600, 178544, 179046, 179110),
>     c(331086, 330620, 330494, 330265, 330075, 330233, 330336, 330004,
>     329783, 329665, 329720, 329933, 330478, 331062, 331086)))),'3')
> sr4=Polygons(list(Polygon(cbind(c(180304, 180403,179632,179420,180304),
>     c(332791, 333204, 333635, 333058, 332791)))),'4')
>
> #Converte em polígonos espaciais
> sr=SpatialPolygons(list(sr1,sr2,sr3,sr4))
> srdf=SpatialPolygonsDataFrame(sr,
> data.frame(row.names=c('1','2','3','4'), PIDS=1:4))
>
> #Cria o shapefile
> writeOGR(srdf, getwd(), 'POLY', 'ESRI Shapefile')
>
> #Leitura do shapefile
> contorno_line_X <- readShapeLines ("POLY.shp")
> df.data = as.data.frame(contorno_line_X)
>
> # Seleciono 2 polígono
> df.serra15e16 = contorno_line_X[contorno_line_X$PIDS%in%c('1', '4'),]
>
>
> #Cria o novo shapefile
> writeOGR(df.serra15e16, getwd(), 'POLY2s', 'ESRI Shapefile')
>
> #---------------------------------------------------------------------------
> ----
>
>
>



Mais detalhes sobre a lista de discussão R-br