Hi All,

Thanks for your responses. I guess there are no efficient way to solve this
problem. At least for this particular SpatialDataFrame object I can solve
the issues by  the following extra four code lines. Since for all my
dataframes (with varying sample sizes) the col names are the same I can put
the whole chunk of code in a function with minimum parameters to change and
run it as many times I want.

Roger: The attribute table of a ESRI shapefile is always in a DBF format. No
work around :(

Thanks,
Debs.

# Changing the col names to get rid off the parantheses, ".", "_", and limit
to 10 chars
names(test500.gwr$SDF)[2]<-"Inter"
names(test500.gwr$SDF)[20]<-"Interse"
names(test500.gwr$SDF)<-gsub("\\.", "", names(test500.gwr$SDF))
names(test500.gwr$SDF)<-gsub("_", "", names(test500.gwr$SDF))

# checking the length of all the strings in the character vector
nchar(names(test500.gwr$SDF))
 [1]  4  9  7  7  6  6  6  7  8  6  8  4  8  8  7  5  5  2  4  7  9  9  8
8  8  9 10  8 10  6 10 10  9  7  7

> names(test500.gwr$SDF)
 [1] "sumw"        "Inter"    "english"      "slope30"      "mac95d"
"mdinc_t"      "musa00"       "popden_t"     "dissewer"
[10] "dismcd"       "diswater"     "ag04"         "c1dishwy"
"c1dipark"     "tccost1"      "soil1"        "soil2"        "R2"
[19] "gwre"        "Interse" "englishse"   "slope30se"   "mac95dse"
"mdinctse"   "musa00se"    "popdentse"  "dissewerse"
[28] "dismcdse"    "diswaterse"  "ag04se"      "c1dishwyse"  "c1diparkse"
"tccost1se"   "soil1se"     "soil2se"

# Converting a "SpatialPointsDataFrame" object to ESRI shape file
# packages rgdal
writeOGR(test500.gwr$SDF, place, "test500gwr", driver="ESRI Shapefile")


On Tue, Jun 17, 2008 at 2:40 AM, Alex Mandel <tech_dev@wildintellect.com>
wrote:

> Roger Bivand wrote:
>
>> On Mon, 16 Jun 2008, Debarchana Ghosh wrote:
>>
>>  Hi,
>>>
>>> I am using R 2.7 on windows with 4GB ram.
>>>
>>> I am trying to convert the SpatialPointsDataFrame object (SDF) from the
>>> "gwr" output ( spgwr package) to ESRI shapefile using the writeOGR
>>> function
>>> from the rgdal package. The function is able to write the shape file with
>>> correct geometry but showing errors when trying to view the attribute
>>> table.
>>> The attribute table is empty. But the data slot of the
>>> SpatialPointsDataFrame object has values for all the columns. Below I
>>> paste
>>> my codes:
>>>
>>
>> The issue seems to be that the underlying DBF format cannot handle field
>> names which are longer than 11 characters. I've looked at:
>>
>> names(test500.gwr$SDF) <- make.names(names(test500.gwr$SDF))
>>
>> and tried abbreviate() too, and toupper() without much luck. Maybe:
>>
>> toupper(gsub("\\.", "_", make.names(substring(names(test500.gwr$SDF), 1,
>>  7), unique=TRUE)))
>>
>> or even less than 7 if need be?
>>
>> What else apart from shapefiles can Arc read that writeOGR can write that
>> would let us get round using DBF?
>>
>> Roger
>>
>>
>>
> It's well known that DBF doesn't support more than 8 characters in field
> names and that Arc doesn't really support much else.
>
> A few options,
> 1. Create a shp with OGR and put the attributes in something like a csv
> then do a join operation in ArcGIS
> 2. Create a geodatabase in ArcGIS (mdb format), write the attributes to a
> table via ODBC, import the separately created shp and join.
> 3. KML, problem again of course is that everything gets converted to shp
>  and hence truncated until you get it into a geodatabase.
>
> Really they are all terrible solutions. In all of them it will have to
> enter shp format at some point which will require the altering of column
> names.
>
> To truly skirt the issue would be to not use Arc at all and use something
> like QGIS,gvSIG or OpenJump which can all read OGR layers - GML, KML are a
> few of the easy ones.
>
> Alex
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Debarchana Ghosh
PHD Candidate | Research Assistant
Department of Geography
University of Minnesota.
PH: 8143607580
www.tc.umn.edu/~ghos0033/

	[[alternative HTML version deleted]]


