Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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 dont tell me, I need a new computer! :)

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

share|improve this question
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

3 Answers 3

up vote 1 down vote accepted

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

http://darrencope.com/2011/03/31/clipping-large-shapefiles-using-ogr/

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

Nick.

share|improve this answer
    
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

(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

then

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
su
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.
KeyFile=$$PGBINDIR/shp2pgsql-gui
Platform=unix
ServerType=postgresql
Database=Yes
SetPassword=No

[Ctrl-D] to exit input mode

# exit

to exit su

Done.

share|improve this answer
    
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. –  m4tts1m 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.

share|improve this answer
    
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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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