[Ottawa_users] Clipping shapefiles with ogr2ogr

Christy Nieman cnieman at connect.carleton.ca
Mon Feb 18 15:23:24 EST 2008


Hi,

I just spent a while working on clipping in QGIS/GRASS, and it is quite 
simple.  I used the GRASS Tools plugin for QGIS to load my shapefiles 
into a GRASS mapset.  I then converted my mapset's region to a GRASS 
vector layer to use as the overlay layer in the clip (v.in.region - 
under Vector/Create standard vectors in the QGIS GRASS tools dialog).  
Then I used the v.overlay intersection tool to do the clip.  This has to 
be done one layer at a time.

If you need more details I can provide a specific example.

Christy

Alyre Chiasson wrote:
> Hello,
>
> I suspected that something like below was happening, although the 
> documentation I read regarding the -spat option presents it as a 
> clipping function. I was surprised by the result. I am new to all of 
> this and have no computer science background so I am not familar with 
> a "bbox" . Although I know Python is a flexible multi platform 
> language (I see a lot of references in the Linux world), attempting to 
> learn the language to write a script to do this job or to understand 
> someone else's script I believe would be beyond my time constraints 
> for the current project. I did try to import both shape files into 
> GRASS as layers and then tried to overlay (v.overlay) them but got 
> error messages which I couldn't understand but were basically 
> complaining about missing attributes. Not sure what attributes it was 
> referring to. Is there actually no way to do this within GRASS or QGIS 
> that retains the feature of the shapefile (everthing within the 
> clipping region) without having to learn a programming language? Would 
> seem to be a desirable function. Not adverse to learning a program 
> language but it would be a much longer term goal.
>
> Thanks
>
> Alyre
>
>
>
> ----- Original Message ----
> From: Tyler Mitchell (OSGeo) <tmitchell at osgeo.org>
> To: Ottawa (Canada) Local Chapter List <ottawa_users at lists.osgeo.org>
> Sent: Monday, February 18, 2008 12:26:36 PM
> Subject: Re: [Ottawa_users] Clipping shapefiles with ogr2ogr
>
> On 18-Feb-08, at 6:22 AM, Paul Spencer wrote:
>
> > My first guess is that ogr2ogr doesn't clip, it uses the bbox as a 
> > spatial selection and keeps anything that intersects with the 
> > bbox.  Would this account for your results?
>
> That's right, it cannot clip, but will select/return all features 
> that fit in the area.  You can't use ogr2ogr for clipping but I 
> believe you could write a Python script that calls the OGR and GEOS 
> functions to do this job.
>
> Tyler
> _______________________________________________
> Ottawa_users mailing list
> Ottawa_users at lists.osgeo.org <mailto:Ottawa_users at lists.osgeo.org>
> http://lists.osgeo.org/mailman/listinfo/ottawa_users
>
>
> ------------------------------------------------------------------------
> Ask a question on any topic and get answers from real people. *Go to 
> Yahoo! Answers.* <http://ca.answers.yahoo.com>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Ottawa_users mailing list
> Ottawa_users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/ottawa_users
>   


More information about the Ottawa_users mailing list