[R-sig-Geo] How to crop a shapefile ?
Dan Putler
dan.putler at sauder.ubc.ca
Thu Dec 17 20:17:21 CET 2009
Hi all,
For this particular problem, Dylan Beaudette is probably exactly right.
However, I ran into problems using similar tools in OpenJump when we
wanted to create a shapefile of a region that we could postal address
geocode against (the way the boundary line segments were clipped was a
problem for the geocoder), which lead me to write tools in R to do it
(outlined in my earlier post). That code does not clip lines, rather it
enable the extraction of the original complete road segments. Since most
of the ways in OSM don't have the attribute information needed for
geocoding, the issue I was addressing won't be relevant here.
Besides GRASS (which can be a bit overwhelming at first), and OpenJump
(mentioned above), the Clip tool within the fTools plug-in for QGIS
should also work. Given the size of the OSM road network files, a
machine with a fair amount of memory will probably be needed to handle
the problem.
Dan
On Thu, 2009-12-17 at 10:27 -0800, Dylan Beaudette wrote:
> > On Thu, 2009-12-17 at 11:07 +0100, Baptiste Coulmont wrote:
> > > Hi,
> > >
> > > I'm working with R and various shapefiles created by the OpenStreetMap
> > > project. Those shapefiles (the roads in particular) are quite big.
> > >
> > > How can I crop (or "trim", or "prune" those objects -- once in a
> > > SpatialLineDataFrame -- if I need to work not on a national level but
> > > on a municipal level ?
> > >
> > > Is it possible to create a subset of a smaller zone ?
> > > Coordinates:
> > > min max
> > > r1 2.560776 6.403847
> > > r2 49.493613 51.505419
> > >
> > > Thansk,
> > > B. Coulmont
>
> This type of work is most efficiently done in a standard GIS. I would suggest
> installing GRASS GIS or something like that. This is a standard vector
> operation, and should be very fast. For this GRASS approach, see the
> v.overlay command.
>
> Cheers,
> Dylan
>
>
>
--
Dan Putler
Sauder School of Business
University of British Columbia
More information about the R-sig-Geo
mailing list