4

I have a SpatialPointsDataFrame with 1057 elements and 4760 columns and want to export it to a shapefile. When I try to do this with writeOGR() I get an error:

> writeOGR(pts,dsn="/home/joana/Desktop/",layer="PT", driver="ESRI Shapefile")
Error in writeOGR(pts, dsn = "/home/joana/Desktop/", layer = "PT", driver = "ESRI Shapefile") : 
 Creating Name field failed

When I reduce the column number, everything works fine.But I really need all of the columns, is there any way to work around it?

I'm using Ubuntu 12.04/R/QGIS

asked Apr 15, 2014 at 8:53
5
  • How are your columns named? The shapefile database has some limitations on field bnames. Commented Apr 15, 2014 at 9:27
  • The most part of them are of this type: "X2012.12.28". But I change them in many ways with no export sucess. Commented Apr 15, 2014 at 9:45
  • They get truncated after 8 characters. This may lead to identical names. Points may also be bad for column names. Commented Apr 15, 2014 at 10:18
  • I tried with "20121228" and it doesn't work. Commented Apr 15, 2014 at 10:25
  • I think that field names must start with a character. But you hit the limited number of fields anyway. Commented Apr 15, 2014 at 10:40

1 Answer 1

1

The shapefile format has some limitations due to the underlying dbase database format.

See:

http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Geoprocessing%20considerations%20for%20shapefile%20output

In your case, the limit of 10 characters field name and 255 fields total is hit.

Try some other format, like spatialite.

Or think about restructuring your database. Insert a new field called date, and store the data underneath instead of side-by-side in one column per day.

answered Apr 15, 2014 at 10:40
2
  • Can you tell me how to export this object from R with spatialite? Commented Apr 15, 2014 at 11:56
  • Should be the same as shapefile, but using another OGR driver. I don't have experience with R, though. Commented Apr 15, 2014 at 12:05

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.