I have a line-shp (80mb) and a polygon-shp (5mb) and want to intersect them. In result, the lines (contours) should be cut by the polygons.

After using one of the tools "Vector -> Geoprocessing -> Dissolve/Clip/Intersect" to do so, the loading bar keeps at 0%. Same by marking just 10 of the 6000 contours to intersect them. The CPU usage is at 50% (one core 100%) all the time, even for more then 30minutes...

What is the problem? How to solve it? But don't tell me, I need a new computer! :)

My config: AMD II X2 240 ; 4GB RAM; xubuntu 12.04; Qgis 1.8

  • 1
    If your contours came from a raster dataset, why not use the raster directly? It is likely this would be a (much) more efficient use of computing resources. – whuber May 23 '12 at 13:51

You could try Darren Cope's method for clipping large shapefiles, it uses ogr2ogr. See:


Added later: Installing QGIS also installs ogr2ogr, so you already have this.


  • That is working perfectly! It still takes some hours but its stable and uses 50% of the CPU so I can do other stuff while cuting my polygons in background! Thaks! – MAP May 25 '12 at 11:10
  • It appears the link is broken. Please summarize what you found in the external resource in your answer. – kontextify Dec 14 '14 at 11:32
  • The link is working for me. – nhopton Dec 14 '14 at 15:07

(i recently had to piece this together for Linux Mint 12 KDE, i expect ubuntu should be identical. You can also refer to http://postgis.refractions.net/documentation/manual-1.4/ch02.html and http://postgis.17.n6.nabble.com/Installing-a-fully-functional-PostGIS-2-0-on-Ubuntu-Linux-GEOS-GDAL-issues-td3566227.html)

Install and configure PostgreSQL (v9.1)

install via Synaptic or

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install python-dev libreadline-dev
sudo apt-get install postgresql-9.1 postgresql-server-dev-9.1 postgresql-contrib-9.1 postgresql-plpython-9.1 

change password method 1

sudo passwd postgres
sudo -u postgres psql postgres

enter password twice on prompts

at psql prompt

postgres # \password postgres

enter password twice on prompts

OR change password method 2

sudo -u postgres psql
postgres # ALTER ROLE postgres WITH ENCRYPTED PASSWORD 'newpassword';
postgres # \q

Install and configure pgAdmin3 (v1.14)

default distro repo only has v1.12 which lacks support for the Postgres 9.1 maintenance features, so instead, do the following:

add apt keyring using standard port (firewall workaround)

gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv 1F9ADD375CA44993
gpg --export --armor 1F9ADD375CA44993 | sudo apt-key add -

add ppa

sudo add-apt-repository ppa:rhonda/pgadmin3

using nano, open ppa list and replace oneiric with natty (this is cheating, but it works), then apt-get update:

sudo nano /etc/apt/sources.list.d/rhonda-pgadmin3-oneiric.list 
sudo apt-get update

pgAdmin3 v1.14 will now be available to Synaptic, or

sudo apt-get install pgadmin3=1.14.0~beta1-1~ppa1~natty1 

Setup pgAdmin3 bin location. Launch pgAdmin3, File > Options > PG bin: /usr/lib/postgresql/9.1/bin/

Install and configure PostGIS (v1.5)

install via Synaptic or

sudo apt-get install postgresql-9.1-postgis


createdb tmplt_postgis
psql -d tmplt_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
psql -d tmplt_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
psql -d tmplt_postgis -f /usr/share/postgresql/9.1/contrib/postgis_comments.sql

(if these paths are incorrect, check Synaptic > postgresql-9.1-postgis > rclick > properties > installed files)

If postgis was compiled with shp2pgsql-gui then add the plugin to pgadmin3. (i think this method is hamfisted, oh well. All you need is a text ini file as shown below)

sudo mkdir /usr/share/pgadmin3/plugins.d
cat > /usr/share/pgadmin3/plugins.d/postgis.shp2pgsql-gui.ini
; pgShapeLoader (Linux):
Title=PostGIS Shapefile and DBF loader
Command=$$PGBINDIR/shp2pgsql-gui -U $$USERNAME -d $$DATABASE -p $$PORT -h $$HOSTNAME
Description=Open a PostGIS ESRI Shapefile or Plain dbf loader console to the current database.

[Ctrl-D] to exit input mode

# exit

to exit su


  • So far, so good :) Thanks a lot!! But i dont understand the last part about shp2pgsql-gui... – MAP May 23 '12 at 17:48
  • Happy to hear it worked! shp2pgsql-gui is a tool for importing shp files into postgis. Look in /usr/lib/postgresql/9.1/bin/. If you have shp2pgsql-gui then you can add the plugin to the pgAdmin3 toolbar by creating a directory and ini file as above. – MrMattSim May 24 '12 at 12:30

I know two Solutions:

1) As Jack the Ripper would say, "let's go by parts". Split your shapes in pieces (copy and paste the desired features in a new file) and run the calculations in each part. IMO this solution is not very practical and prone to errors.

2) Use other software. Most of the software uses GEOS library for this kind of operation, but they may have different ways of sending data to the library. My No 1 suggestion is Postgesql with Postgis, I've done very large calculations like yours with Postgis, with it you can also tweak the query for better results/performance. No 2 is GRASS gis, it's well known for it's abilities to handle big tasks.

About the your computer, most of the softwares won't use more than 1 processor at a time unless you split the job and create many threads of the task you want to run, you can do that running many instances of a GRASS command (I'm not sure about qgis). And, if you are skilled with python, you can program a multicore application to do that for you if you need to deal with big datasets many times.

  • PostGIS! That should it be, BUT: I tryed to install it several times but I surrendered... Im very new to ubuntu and Im a unexperienced user... do you have any very easy step-by-step instruction to install and use postgis with qgis in ubuntu? – MAP May 23 '12 at 13:10
  • There is a procedure to install Postgis on Ubuntu, Google it. There is also this pack: opengeo.org/technology/suite that is very easy to install, but it will install some other tools. – Pablo May 24 '12 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.