Ale,

Some remarks between the lines:

Alessandro schreef:

Thanks for All help give me.

I spoke with my professor and now I must do some changes. After subtract the column Z with clomun DEM_SGRD to obtain column H. I wish to create a new shape with only this H column. I tried and tried but when I write the shape file there is always an error.

Sorry for all disturb.

I don’t want to be ill-mannered, to use improperly your time, but before to save the shape is It possible to save only all records with H value > of 2. (the statistical analysis need this clean)

Thanks

Ale

> prova <- readOGR(".", "prova")

OGR data source with driver: ESRI Shapefile

Source: ".", layer: "prova"

with 42 rows and 2 columns

> summary(prova)

Object of class SpatialPointsDataFrame

Coordinates:

min max

coords.x1 267980.1 267998.1

coords.x2 4147799.4 4147818.8

Is projected: NA

proj4string : [NA]

Number of points: 42

Data attributes:

Z DEM_SGRD

Min. :1415 Min. :1412

1st Qu.:1419 1st Qu.:1413

Median :1421 Median :1414

Mean :1423 Mean :1414

3rd Qu.:1424 3rd Qu.:1415

Max. :1437 Max. :1417

> prova$H <- prova$Z - prova$DEM_SGRD

> summary(prova)

Object of class SpatialPointsDataFrame

Coordinates:

min max

coords.x1 267980.1 267998.1

coords.x2 4147799.4 4147818.8

Is projected: NA

proj4string : [NA]

Number of points: 42

Data attributes:

Z DEM_SGRD H

Min. :1415 Min. :1412 Min. : 3.169

1st Qu.:1419 1st Qu.:1413 1st Qu.: 5.612

Median :1421 Median :1414 Median : 7.320

Mean :1423 Mean :1414 Mean : 9.265

3rd Qu.:1424 3rd Qu.:1415 3rd Qu.:10.982

Max. :1437 Max. :1417 Max. :21.806

> prova2 <- prova$H

Here you extract the data from prova, not including the coordinates. Look at class(prova2) to see that it is no longer a SpatialPointsDataFrame but a data.frame. Use the following syntax to get the data plus the coordinates:

prova2 <- prova["H"]

Now you can export it using write OGR. To get only the values above H == 2:

prova_Hgt2 = prova2[prova2$H > 2,]

Or combining the two actions above into one command:

prova2 = prova[prova$H > 2, "H"]

cheers,
Paul

> summary(prova2)

Min. 1st Qu. Median Mean 3rd Qu. Max.

3.169 5.612 7.320 9.265 10.980 21.810

> writeOGR(prova2, ".", "prova2", driver="ESRI Shapefile")

Errore in writeOGR(prova2, ".", "prova2", driver = "ESRI Shapefile") :

obj of wrong class

------------------------------------------------------------------------

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to