[R-sig-Geo] Subsetted SpatialPolygonsDataFrame cannot writeOGR to ESRI shapefiles
christiaan pauw
cjpauw at gmail.com
Fri Jun 4 05:44:37 CEST 2010
Thanks Roger.
I get the following from my gdal_version.h
GDAL_RELEASE_DATE 20100423
GDAL_RELEASE_NAME "1.7.2"
Downloaded rgdal yesterday from
http://www(dot)kyngchaos(dot)com/files/software/unixport/rgdal-0.6.26-1.zip
I am on Mac OS X 10.5.8
I place the data files together with a sample program here:
https://sites(dot)google(dot)com/site/christiaanpauw/file-cabinet
There is one thing that I noticed while uploading the files that
strikes me as strange. The total size of the SPDF is 28k (containing
144 polygons with an associated dataframe with 3 variables) while the
dataframe(containing 144 rows of 19 variables) in 1.4M. Is it possible
that there is something corrupt in the dataframe that only comes to
the fore in the writeOGR operation?
Thanks for your help
best regards
Christiaan
On 3 June 2010 09:03, Roger Bivand <Roger.Bivand at nhh.no> wrote:
>
> On Thu, 3 Jun 2010, christiaan pauw wrote:
> Please make the input data objects to spCbind available on a website, with a copy of the spCbind command. Use save() to save as a portable RData file. Please also report your exact GDAL version and source, as this may also be platform dependent.
>
> Roger
>
>> Thanks to Rick and Roger for their respective replies. Both helped.
>>
>> I updated R, GDAL and rgdal (I now have: R version 2.11.1
>> (2010-05-31) x86_64-apple-darwin9.8.0 with rgdal_0.6-26).
>> I then Ricks proposed writeOGR statement below. This works.
>>
>> After adding some data (a dataframe called Bluegum) to the data already
>> contained in the SPDF with spCbind like this:
>>>
>>> SPbluegumADD=spCbind(SPbluegumImP,Bluegum)
>>
>> I get a SpatialPolygonsDataFrame (according to class()) that can be plotted
>> and looks OK on the plot. I can even use the newly added variables to define
>> colours in the plot so I am sure the spCbind was successful.
>>
>> But when I try to write it to a shapefile I get an error again:
>>
>>> writeOGR(SPbluegumADD,".","SPbluegumImPX",driver="ESRI Shapefile")
>>
>> Error in writeOGR(SPbluegumADD, ".", "SPbluegumImPX", driver = "ESRI
>> Shapefile") :
>>
>> GDAL Error 1: Invalid index : -1
>
>
More information about the R-sig-Geo
mailing list