I have to store longitude and latitude coordinates for several places in a PostgreSQL db table. Each row in this table has a field with a set of pairs {latitude1, longitude1, ....latitudeN, longitudeN} wich represent an enclosing polygon.

I stumbled upong PostGIS, and I'm wondering if it is necessary to use Polygon datatype for this particular field in my table, like depicted in this example

I'm asking because the only thing I'm gonna do with those polygons is drawing them afterwards in a Google Maps, I don't really think I'm gonna do any reasoning on them (yet)...thus, would be PostGIS overkill for this? Besides all the time I have to spend in installing and learning PostGIS...

Any toughts?


  • How many features do you have? Do you have experience with [other] databases or GIS tools? – Dylan Hettinger Aug 26 '13 at 21:27
  • I have experience with Postgre and other relational db, but never had to use GIS tools. I don't get your question about features? You mean in the app I'm developing? – AlejandroVK Aug 26 '13 at 21:44
  • I mean the number of polygons you want to display. – Dylan Hettinger Aug 26 '13 at 21:46
  • Not a lot, probably within the 25-50 range – AlejandroVK Aug 26 '13 at 21:58

In general, a database solution will be most useful if you have a large number of features or need to filter or combine data. Do you want to display only polygons of a certain kind? Only polygons within 10 miles of a user-generated point? Do you need to know how much area each polygon covers? Or do you want to know how many features in another table share some attribute? Those are all good reasons to use a database where you can take advantage of the plethora of spatial functions and indexing options.

Even if you don't need to answer those kinds of questions, you still might consider storing your features in Postgres as polygons simply because it's nice to have all the data in one place and using Postgis is the "right way" to store spatial data in Postgres- especially if you are already using a Postgres DB for other data. The install should be fairly straightforward in any reasonably modern environment.

PostGIS is my go-to GIS these days, but if I had a small number of features (say, in the hundreds) and I didn't have Postgis available on the production machine already I would consider other options like creating a shapefile or KML or GeoJSON of the polygons. You might even consider SpatialLite that sits on top of SQLite. It sounds like you're going to have to write some script to create polygons anyway, so you could just write that in javascript or whatever server side language you're using and leave it there, though that generally offends my sensibilities.

  • Sounds reasonable...I'll go for PostGIS then. Front-end is gonna be a Google GWT app, so I'll be using Java Google Maps API for drawing the polygons. As for the data, it will be obtained from a REST call in JSON format. I have a back-end that gets the data from the db and the generates the JSON message upon HTTP GET requests. – AlejandroVK Aug 26 '13 at 23:09

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.