<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=windows-1252"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
<big>Thanks! I am trying to write a function to merge or combine
several shape files. <br>
<br>
First I try to use following function when all shape files in one
folder. It showed error. <br>
<br>
</big><small><font face="Courier New, Courier, monospace">setwd("E:/Zia/SURRGO_Data/SSURGO_RAW_DATA/Test1")<br>
library(rgdal)<br>
## obtain shapefile names in current directory<br>
fs <- list.files(pattern = "shp")<br>
## read the first one<br>
d <- readOGR(fs[1], gsub(".shp", "", fs[1]))<br>
for (i in 2:length(fs)) {<br>
d.tmp <- readOGR(fs[i], gsub(".shp", "", fs[i])) <br>
}<br>
d <- rbind(d, d.tmp)<br>
</font></small>> d <- rbind(d, d.tmp)<br>
<font color="#ff6600">Error in validObject(.Object) : <br>
invalid class "SpatialPolygons" object: non-unique Polygons ID slot
values<br>
</font><br>
<big><br>
Then I am trying to use following code, but it did not work. it <font
face="Courier New, Courier, monospace"><u>created a empty layer. </u><font
face="Times New Roman, Times, serif">I think I did something wrong.
Any idea, </font></font><u><font face="Courier New, Courier, monospace"></font></u><br>
<br>
</big><small><font face="Courier New, Courier, monospace"># Code for
similar file name (shape.shp)<br>
setwd("E:/Zia/SURRGO_Data/SSURGO_RAW_DATA/Testf")<br>
library(rgdal)<br>
<br>
files <- list.files(pattern = "shp") # get all the names in the
directory<br>
files <- files[file.info(files)$isdir] # only keep the directories<br>
<br>
layer<- file('layer.shp') # output file<br>
for (Dir in files){<br>
input <- readOGR(file.path(Dir, "shape.shp")) <br>
rbind(input, layer) <br>
}<br>
close(layer)</font></small><br>
<br>
<big>I have a situations like all shape files are different names
(like...001.shp, ...003.shp, ....005.shp so on ) and were saved in
different folders (like fn001, fn003, fn005.......
If someone helps me to write correct code for solving this it will be
great. <br>
<br>
Zia </big><br>
<br>
Hannes Reuter wrote:
<blockquote cite="mid:4B56B77B.3020203@web.de" type="cite">Dear Zia,
<br>
<br>
1)check GDAL (<a class="moz-txt-link-abbreviated" href="http://www.gdal.org">www.gdal.org</a>) using the ogr2ogr function -append as well
as the RGDAL library out.
<br>
2)
<br>
3) -->gdal_rasterize --> check as well the RGDAL library out.
make sure you have a decent version of RGDAL/GDAL as I believe that the
rasterize just came in the las two versions or so.
<br>
<br>
hannes
<br>
<br>
Zia Ahmed schrieb:
<br>
<blockquote type="cite">Hi:
<br>
I like use R for data mining, organization, manipulation and mapping of
SSURO data of USA. I have already done first two; I need help for
mapping these data.in R It will be appreciated if someone helps me to
solve following three issues:
<br>
<br>
*1. How do I merge several shape files?*
<br>
I like to merge several shape files to create a single shape file. All
files are same structure but different names and in different folders.
Below I mentioned how all shape files are organized in different
folder. I want to write a function that I can use to merge the shape
files.
<br>
<br>
*File organization:*
<br>
…/State_name/soil_ia001/spatial/file_name01.shp
<br>
…/State_name/soil_ia003/spatial/file_name03.shp
<br>
…/State_name/soil_ia005/spatial/file_name05.shp
<br>
.
<br>
. …/State_name/soil_ia21/spatial/file_name21.shp
<br>
<br>
*DBF file associated all shape files look like below: *
<br>
<br>
ID AREASYMBOL SPATIALVER MUSYM MUKEY
<br>
1 IA001 2
822D2 402210
<br>
2 IA001 2
24C2 402161
<br>
3 IA001 2
93D2 402217
<br>
4 IA001 2
W 1857266
<br>
5 IA001 2
W 1857266
<br>
6 IA001 2
370C 402177
<br>
7 IA001 2
570B 402190
<br>
-------
<br>
*
<br>
2. My second question is: I like to join a table with this above
mentioned shape using a conmen ID like MUKEY. How do I do this?*
<br>
*3. My third question is: how do I convert this shape file to a
grid (as a TIFF format or others? ) that I open some other software?*
<br>
<br>
Thanks
<br>
Zia
<br>
<br>
<br>
_______________________________________________
<br>
R-sig-Geo mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:R-sig-Geo@stat.math.ethz.ch">R-sig-Geo@stat.math.ethz.ch</a>
<br>
<a class="moz-txt-link-freetext" href="https://stat.ethz.ch/mailman/listinfo/r-sig-geo">https://stat.ethz.ch/mailman/listinfo/r-sig-geo</a>
<br>
</blockquote>
</blockquote>
</body>
</html>