I am getting an "unknown structure error" when using arc.write from the latest arcgisbindings pkg. I tried to follow the example in the package vignette for arc.write. I am guessing it is not using the correct coords or shape_info like it should...Any idea how should I fix this? Here are my steps:
1) Reading a polygon shp,
2) Extracting its data.frame,
3) Joining it with an existing R data.frame (by a common attribute name)
4) Saving it back to a new shp
...
fc <- arc.open(<input_shapefile>)
fc.df <- arc.select(fc)
fc.df_join <- left_join(fc.df, <existing_dataframe>, by = 'ISO_3_CODE')
dim(fc.df_join)
[1] 211 11
arc.write(path="./output.shp", data=fc.df_join,
coords = arc.shapeinfo(fc)$WKT,
shape_info = arc.shapeinfo(fc))
Error in .call_proxy("arc_export2dataset", path, data, coords, shape_info) :
unknown structure
In addition: Warning message:
In .call_proxy("arc_export2dataset", path, data, coords, shape_info) :
length of shape != data.frame length
Hello Francesco,
I think what's happening is that after you've performed the join, the data frame structure is changed to accommodate the join. So the rows don't line up with what arcgisbinding expects, and there's a mismatch between data structures. I've discussed this with another developer, and probably the most robust way for us to support this is to implement direct support for the dplyr style joins. For now, please see this example which uses spdplyr to do the join with sp class objects:
https://community.esri.com/thread/196578-impossible-to-use-dplyr-join-functions-on-data-frames
Cheers,
Shaun