Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a PostGIS dataset with just over 2 million rows. Each row has a PostGIS geometry point value and several attributes.

I'd like to do some analysis on certain subsets of the data, but I can't figure this out. Is there a way of querying data once you have it in GRASS GIS? Alternately, is it possible to leave the attribute data back in Postgres, and then do queries or filters based on this data?

For example, suppose that my 2+ million rows had a boolean column X. How would I run GRASS analysis on the entire dataset, then immediately do the same analysis on only the data where this column is set to false?

share|improve this question

You can use to import PostGIS vectors into GRASS, and use the "where=" option to filter out only those rows you want. Additionally, if you set the database connection in GRASS to postgres, then the attribute table will be stored back into the Postgres database, and the vector geometry will be stored in GRASS for further analysis. So (copied from the manual pages):

db.connect driver=pg database="host=my.postgis.server,dbname=mydb"
db.login user=myname [pass=secret]
db.connect -p dsn="PG:host=my.postgis.server dbname=mydb user=myname" layer=mypoints \
    output=mypoints_grass type=point \

Please note: YOu must use a different name for the GRASS vector. If you're storing the attribs in the same Postgres database as the original PostGIS points, then there will be a conflict of table names otherwise.

share|improve this answer

Your Answer


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.