2

Can writeSpatialShape { maptools } be somehow forced to write the shapefile with CRS?

writeSpatialShape(socc_buf, "f:/hdf/socc_buff_R.shp") # no CRS in the shapefile

There does not seem to be an option for this.

PS: I know it can be done using writeOGR { rgdal }.

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • 1
    Unless something changed and I doubt, I think is not possible (source : Roger Bivand) https://stat.ethz.ch/pipermail/r-sig-geo/2011-November/013568.html – dickoa Jul 20 '13 at 11:07
  • 1
    Why don't you want to use `writeOGR` ? – dickoa Jul 20 '13 at 11:07
  • @dickoa I am using it, I am just curious about writeSpatialShape. Thanks – Tomas Jul 20 '13 at 12:52
  • 2
    a reason for not using writeOGR is, that it rediculously abbreviates your column names with shape files -> unusable for me when i mass-produce layers where I then have to restore the column names manually. writeSpatialShape doesn't produce the .prj, but with that I can live. If only writeOGR for spatialite was able to add layers to an existing db, live would be perfect. – Bernd V. Dec 02 '14 at 17:17
  • Thanks @BerndV. for pointing out the problem (here I found more information: http://gis.stackexchange.com/q/30785), but according to the information given there this is not problem of `writeOGR`, but of the `dbf` format. If you don't agree please post followup comment [right there](http://gis.stackexchange.com/a/35111/4630). – Tomas Dec 04 '14 at 17:03
  • Its true that dbf accepts only 10 characters as field names. But writeOGR even cripples fields with only 7 or 8 or even less characters.(Example: "ora_nachwe" becomes "or_nch_" ! Thats why I can't use it to produce output I want to work with, but use writeSpatialShape now, where it is one click in QGIS to assign a projection, while with writeOGR I have to work 5 + minutes to restore fieldnames. – Bernd V. Dec 04 '14 at 17:55

1 Answers1

0

TMS

You need to remove the .shp from the filename as it creates a .shp .shx and .dbf file. According to the package manual "fn shapefile layer name, when writing omitting the extensions *.shp, *.shx and *.dbf, which are added in the function"

Thanks

tony.