[R-sig-Geo] gUnion

Joseph Bechara jbechara at lri-lb.org
Thu Sep 26 09:54:26 CEST 2013


Thanks Mike this was very useful.

In fact I want to clip the raster to try the gUnion function to dissolve some  features.

The gUnion is working but it is giving me a SpatialPolygons and not a SpatialPolygonsDataframe .

Which make me loose the attribute table when I’m exporting the output shapefile. 

Any hints?

 

 

Thermo <- readOGR("//MAPPING-SERVER/Data/JosephVegMap/RS/Exported_New/thermo_n", layer="Thermo_n")

library(rgeos)

#Thermo

#call the head of the Thermo attribute table

VV<-Thermo at data

TT<-gUnaryUnion(Thermo,VV$Class_name)

 

JOSEPH BECHARA

Wildfire Management Program Coordinator

Ashrafieh 1020 Building, 8th floor, Mathaf, Beirut, Lebanon

Tel.: +961 (1) 426630-1-2

Fax: +961 (1) 426631

Mail:  <mailto:jbejjani at lri-lb.org> jbechara at lri-lb.org

 <http://www.lri-lb.org/> www.lri-lb.org

Description: Description: LRI-logo-Email

 

 

From: Michael Sumner [mailto:mdsumner at gmail.com] 
Sent: Wednesday, September 25, 2013 11:21 PM
To: Joseph Bechara
Cc: RsigGeo
Subject: Re: [R-sig-Geo] clip shape file

 

I use code like this: 

 

## UNTESTED

library(rgdal)

d <- readOGR("/path/to/file", "shpfile")

 

## use raster for an easy shortcut to build a clipping def

library(raster)

## dummy values, 

ext <- extent(0, 100, 10, 90)

clipe <- as(ext, "SpatialPolygons")

proj4string(clipe) <- CRS(proj4string(d))

cropd <- SpatialPolygonsDataFrame(clipe, data.frame(x = 1), match.ID = FALSE)

 

## Now do the clip

library(rgeos)

res <- gIntersection(d, cropd)

 

 

Now, for questions like this you should provide the code you are trying with even if it doesn't work so we don't have to make it up. 

 

Cheers, Mike. 

 

On Wed, Sep 25, 2013 at 11:13 PM, Joseph Bechara <jbechara at lri-lb.org> wrote:

Hello, 

 

I’m trying to clip a shapefile with an extent.

Unfortunately it is not working.

Can somebody give me a hint?

 

JOSEPH BECHARA

Wildfire Management Program Coordinator

Ashrafieh 1020 Building, 8th floor, Mathaf, Beirut, Lebanon

Tel.: +961 (1) 426630-1-2

Fax: +961 (1) 426631 <tel:%2B961%20%281%29%20426631> 

Mail:  <mailto:jbejjani at lri-lb.org> jbechara at lri-lb.org

 <http://www.lri-lb.org/> www.lri-lb.org

 

 


_______________________________________________
R-sig-Geo mailing list
R-sig-Geo at r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo







-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130926/545f2e17/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 16370 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20130926/545f2e17/attachment.jpe>


More information about the R-sig-Geo mailing list