1

I'm extracting data using a point shapefile and currently am able to write an output file for only one point shapefile using the below code.

file<- "soil.sil"
write.table("[thickness]\nunit=m",file, append = TRUE, row.names=FALSE, quote=FALSE, col.names=FALSE)
write.table(paste0("1=",L1), file, append = TRUE, row.names=FALSE, quote=FALSE, col.names=FALSE)
write.table(paste0("2=",L2), file, append = TRUE, row.names=FALSE, quote=FALSE, col.names=FALSE)

I would however want to write separate output files given several points. How can I accomplish this?

The file structure is such that details are listed down, here is a sample

[soil]
[thickness]
unit=m
1=0.05
2=0.1
jmutua
  • 290
  • 1
  • 12
  • What kind of structure are you trying to output? – Roman Luštrik Aug 11 '15 at 07:53
  • And what would be your file naming pattern? – vaettchen Aug 11 '15 at 07:55
  • @RomanLuštrik I've edited the question and added a sample file structure – jmutua Aug 11 '15 at 08:28
  • @vaettchen, I've edited the question – jmutua Aug 11 '15 at 08:29
  • Are you aware that `write.table` writes data.frames and matrices? Where is this 'one point shapefile'? What is `hg1`? – Roman Luštrik Aug 11 '15 at 09:09
  • @RomanLuštrik I've edited the code to respond to your question, the above code will produce the sample output. In my case I mentioned that this is working for one xy coordinate, what of several xy coordinates? – jmutua Aug 11 '15 at 11:37
  • Sorry but still your question is not clear. What you say is that `soil.sil` consists of many entries similar to what is at the bottom of your question? And what you want to do is read that one file and distribute the five lines to one file each? – vaettchen Aug 11 '15 at 12:51
  • @RobertH Am extracting values from rasters using xy coordinates, am then writing each output separately (I've done this but for one xy coordinate). My question is how to accomplish this for several xy coordinates. – jmutua Aug 11 '15 at 13:03
  • Why dont you `dput( head( original.data ) )` or something to that effect, and then tell us exactly what each derived file should look like, and how you want to have them named? It doesn't sound like an overly difficult problem, but with the present level of information, nobody can work. – vaettchen Aug 11 '15 at 13:15
  • I agree with vaettchen, [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) is in order. – Roman Luštrik Aug 11 '15 at 14:46
  • Can I high-jack this question to make it reproducible? – derelict Feb 26 '16 at 19:53

0 Answers0