[Ottawa_users] Clipping shapefiles with ogr2ogr

Alyre Chiasson alyre.chiasson at gmail.com
Wed Feb 20 08:42:22 EST 2008


Hi Christy,

Thanks for the offer of help. I believe I understand your instructions. 
I have gotten as far as having the GRASS clip mask and the underlying 
GRASS layer from which I want to retain the underlying feature. So if I 
could cut out what is under the mask, I would have my desired result. 
Look good at this stage on the screen. However, when I execute the 
v.overlay I get the following error, "Database connection not defined 
for layer 1" No layer is created and QGIS freezes then crashes when I 
try to exit. Any idea what this message means. Seems like some related 
to the database pathway? Did something not get properly imported from 
the shapefiles? How do I correct it?


Thanks

Alyre




Loader

Christy Nieman wrote:
> 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
>>   
> _______________________________________________
> 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