[R-sig-Geo] regression and cluster analysis with shapefiles: data import problems

Danlin Yu yud at mail.montclair.edu
Tue Apr 25 23:18:40 CEST 2006


Anja:

If you have a shapefile imported using read.shape, you can view the header (the attribute names) of your shapefile object using "colnames(shapeobject$att.data)"

Similarly, you can assign individual attributes as R objects using command like:

attribute1 <- shapeobject$att.data$attribute1

For polygons, you can get the X, Y, coordinates by using get.Pcent (shapeobject) in the package maptools (which will be loaded when you load the package spdep). I am quite sure you can do similar work with point file as well (Roger mentioned that to me once, but since I have access to ArcGIS, and as a habit I always creat the X, Y fields for my data, I forgot the procedure).

Hope this helps.

Cheers,

___________________________________________
Danlin Yu, Ph.D.
Assistant Professor
Department of Earth & Environmental Studies
Montclair State University
Montclair, NJ, 07043
Tel: 973-655-4313
Fax: 973-655-4072
email: yud at mail.montclair.edu

----- Original Message -----
From: Anja Matatko <Anja.Matatko at alta4.com>
Date: Tuesday, April 25, 2006 11:37 am
Subject: [R-sig-Geo] regression and cluster analysis with shapefiles: data import problems

> 
> Dear list,
> 
> I have a shapefile with several numerical attributes and want to 
> do cluster and regression analysis with this data 
> (sociodemographic data). I use the read.shapefile-command to 
> import my data (it is well imported, it appears as an object), and 
> then my first problem occurs: 
> 
> I want to do the analysis as in Anselin's "An Introduction to 
> Spatial Regression Analysis in R" or the FAO publication by 
> Petrucci / Salvati / Seghieri "The application of a spatial 
> regression model to the analysis and mapping of poverty", but they 
> all use other raw data than shapefiles and I couldn't find a hint 
> how to convert my shapefile to a format that supports the lm() or 
> similar functions. 
> 
> I think there are two problems to solve:
> 
> - I need to have access to the headers of my shapefile attribute 
> data, in order to execute commands as mydata$variable1 (actually, 
> I can't call mydata$variable1, I just get the answer NULL)
> 
> - I need something to get the spatial information contained in the 
> shapefile (my attribute table has no x y coordinates included). Or 
> is it really necessary to insert x and y columns in the attribute 
> table with the help of ArcGIS? 
> 
> Thanks for help,
> 
> Anja (student of applied geography writing masters thesis about 
> the use of geographical information systems and several "spatial 
> statistics software" - including R - in planning support, in 
> domains not much affiliated to spatial analysis but working with 
> spatial data)
> 
> 
> 
> -------------------------------------------- 
> Anja Matatko
> alta4 Geoinformatik AG 
> Frauenstraße 8-9 
> 54290 Trier/Germany 
> voice: +49.651.96626-0
> fax: +49.651.96626-26 
> email: anja.matatko at alta4.com 
> internet: http://www.alta4.com 
> 
> Die nächsten GIS-Schulungen:
> - ArcGIS 9 Umsteiger: 15. - 17.05.06 in München
> - ArcGIS 9 Geoprocessing & Model Builder: 18. - 19.05.06 in München
> - What's New in ArcGIS 9.1?: 22.-23.05.06 in Trier
> - ArcGIS Digitalisieren: 02.06.06 in Trier
> Weitere Infos: http://www.alta4.com/de/schulung/index.php
> 
> Treffen Sie uns auf folgenden Veranstaltungen:
> - IT-Messe: 04.-05.05.06 in Trier
> - ESRI Anwenderkonferenz: 09.-11.05.06 in Salzburg
> Weitere Infos: http://www.alta4.com/de/alta4/events.php
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>




More information about the R-sig-Geo mailing list