10

I'm just getting started in GIS and am interested in using it to create maps of mountain biking trails in my area and nearby. I've been learning QGIS and have made enough progress to generate a decent map. So far I've been storing my layers in Shapefiles, which seems to be working okay.

This past weekend I started looking at PostGIS and have it up and running and managed to import my trail shapefiles and connect QGIS to PostGIS.

I'm now wondering what the pros and cons of using a database versus files would be. I have some thoughts already, but am curious what enlightening opinions others may have.

Pros of Database

  • One table for all my trails, regardless of park, allows me to have a consistent set of columns for the information.
  • Easier to query/export my data to multiple formats
  • Multiple clients/tools allow for easier viewing and editing of data
  • Easier editing of table structure (compared to QGIS table editing)

Cons of Database

  • Standing up/maintaining a database adds complexity to my setup.
  • I have a desktop and a laptop I do my GIS work on and using DropBox allows me to easily sync files between the two machines. This likely won't be possible (or as transparent) using PostGIS as using DropBox with files.
  • Easier to backup/restore files than a database.
1
  • 1
    If map will be read only and stay under 2gb, stick with shape files. If you plan on having multiple simultaneous edits and it being a bigger than 2gb dataset, go with postgis.
    – CaptDragon
    Jan 3, 2012 at 16:48

6 Answers 6

13

I suggest you to add Spatialite to your list. It has the benefits of being file based (as a shapefile, or an .mdb database) and supports most of the usual spatial operators and tpyes, that you can find in PostGIS too. Spatialite is based on Sqlite, so you will manage a single file, that you can easily move and share.

1
  • I will take a look since, from your description, it seems to offer the best of both worlds. Jan 5, 2012 at 4:29
6

I'd say the biggest Pro on a PostGIS database is, that you can work with the whole function set PostGIS gives you.

All the Cons in your list, are all very easy fixable. You can run Postgis on ONE server and use your laptop and desktop as a client. The backup question as well, you can generate dump files or what-so-ever to have a good and valueable backup! ;)

2
  • I like to use my laptop on train rides though, so I don't have any internet connectivity at that time. Jan 3, 2012 at 12:25
  • @Styp, if you have the PostGIS server and client on a single laptop, it works just fine!
    – Simbamangu
    May 8, 2014 at 14:03
5

Another big plus for PostGIS is that with spatial databases you can keep one copy of the spatial data and create views that link to your non-spatial data via a unique id.

Then you can create subsets of your full data by creating views that select from it - so you can do single-state tables as views of a full country table. SOmething like:

create view txcounties as select * from counties where state = 'TX'

Also nobody seems to have mentioned the speed of spatial operations for PostGIS. Suppose you want to see what the nearest waterfall was to your bike trails, given a table of lines of trails and a table of points of interest including waterfalls. That's the kind of query that PostGIS can do really quickly since it keeps spatial indexes on the spatial tables. You can probably do it with the native tools in Qgis but it might be quite a bit slower.

Obviously for a fun little application like yours these things are probably not a good reason to get into the complexity of a spatial database, but it might explain why these 'enterprisey' features are essential for bigger projects.

1
  • I read the free chapter of "PostGIS in Action" which led me to the same conclusion as you - very powerful stuff but likely overkill (right now) for what I want to be doing with it. Jan 5, 2012 at 4:28
2

Another advantage of DB vs. flat files is versioning, crucial for multiuser data-entry GIS.

There's a beta plugin for PostGIS and GeoGit, cf. this question.

1
  • I'm working solo, so I updated the question to reflect that. Your point is valid though. Jan 5, 2012 at 15:06
1

There is a limitation in Shape file (max 2gb).. so if your map size is not going beyond this limit.. you can use the shape file without any db setup....

1
  • That's a good point (but please note that the 2 GB limit applies equally and separately to the features in the .shp file and to the attributes in the .dbf file). However, the question invites comparisons between the shapefile solution and the DB solution. How do the shapefile file size limitations compare to similar limitations, if any, in the database files?
    – whuber
    Jan 3, 2012 at 16:52
1

old thread I know.

I would also add that - as a solution mechanism, Geopackages are now a good halfway point between the two options, offering a good mix of the solution benefits of both file/db solutions.

2
  • Would you please explain more in-depth what you mean about this "halfway point"? From what I see, .gpkg files are just another extension and i've never seen a reason to use this format, but I've never worked with databases and PostGIS.
    – Eric Lino
    Feb 9, 2021 at 21:49
  • I wouldn't call them a fully fledged database, but they aren't just a simple file extension either. Hence 'half way point'... half way between a flat file and a database.
    – nr_aus
    Feb 11, 2021 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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