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:

# packages spgwr, maptool, sp, foreign
# Finding the bandwidth by the AIC method
test500.bw.aic<-gwr.sel(yimp00~ english + slope30 + mac95d + mdinc_t +
musa00
  + popden_t + dissewer + dismcd + diswater + ag04 + c1dishwy + c1dipark +
tccost1 + soil1 + soil2,
  data=base500vars, coords = cbind(base500vars$longx, base500vars$laty),
method = "aic", longlat=TRUE)

# gauss gwr function
test500.gwr<-gwr(yimp00~ english + slope30 + mac95d + mdinc_t + musa00 +
popden_t + dissewer + dismcd + diswater
  + ag04 + c1dishwy + c1dipark + tccost1 + soil1 + soil2, data=base500vars,
  coords = cbind(base500vars$longx, base500vars$laty), longlat=TRUE,
bandwidth = test500.bw.aic,
  hatmatrix=TRUE, se.fit=TRUE)

# output of gwr
names(test500.gwr)
[1] "SDF"       "lhat"      "lm"        "results"   "bandwidth" "adapt"
"hatmatrix" "gweight"   "this.call"

class(test500.gwr$SDF)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"

> names(test500.gwr$SDF)
 [1] "sum.w"          "(Intercept)"    "english"        "slope30"
"mac95d"         "mdinc_t"        "musa00"         "popden_t"
 [9] "dissewer"       "dismcd"         "diswater"       "ag04"
"c1dishwy"       "c1dipark"       "tccost1"        "soil1"
[17] "soil2"          "R2"             "gwr.e"          "(Intercept)_se"
"english_se"     "slope30_se"     "mac95d_se"      "mdinc_t_se"
[25] "musa00_se"      "popden_t_se"    "dissewer_se"    "dismcd_se"
"diswater_se"    "ag04_se"        "c1dishwy_se"    "c1dipark_se"
[33] "tccost1_se"     "soil1_se"       "soil2_se"

# I changed the names of column 2 and 20 to "Intercept" and "Intercept_se"
because ESRI shapefiles does not like brackets
> names(test500.gwr$SDF)[2]<-"Intercept"
> names(test500.gwr$SDF)[20]<-"Intercept_se"
> names(test500.gwr$SDF)
 [1] "sum.w"        "Intercept"    "english"      "slope30"
"mac95d"       "mdinc_t"      "musa00"       "popden_t"     "dissewer"
[10] "dismcd"       "diswater"     "ag04"         "c1dishwy"
"c1dipark"     "tccost1"      "soil1"        "soil2"        "R2"
[19] "gwr.e"        "Intercept_se" "english_se"   "slope30_se"
"mac95d_se"    "mdinc_t_se"   "musa00_se"    "popden_t_se"  "dissewer_se"
[28] "dismcd_se"    "diswater_se"  "ag04_se"      "c1dishwy_se"
"c1dipark_se"  "tccost1_se"   "soil1_se"     "soil2_se"

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

I cannot seem to find the error. Is there any other way to write the
'SpatialPointsDataFrame' object to ESRI shapefiles?

Any pointers will be very helpful.

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

	[[alternative HTML version deleted]]


