2

I have three different type of geospatial data Road Direction, Pinpoint location with/without radius, Custom define area which I want to store. If I understood it right this would need three different data types for postgis column, LINESTRING, POINT, POLYGON respectively.

Now the problem for me is these three different types represents a single entity which you can say place_user_interested_in

Can I store these three different types in single column?

The reason why should I store this in single column is to make it more flexible to add more data types later if needed and it would be easier to perform same actions on all of these in single query and some other relevant stuff

  • 2
    Just create the geometry column as general "geometry" and you can store all kind of geometries into it. – user30184 May 27 '18 at 11:31
5

As pointed out in the comment and in one of my questions (and the answers therein) - What's the benefit of heterogeneous geometry column in PostGIS?, you can store different types of geometry in the same field, if you don't specify specific geometry type. i.e. if you create your table as follows:

CREATE TABLE tbl AS (..., geom geometry); 

, instead of giving the field a specific type

CREATE TABLE tbl AS (..., geom geometry(linestring));

OR

CREATE TABLE tbl AS (..., geom geometry(multilinestring));

etc.

In the first approach, you can store mixed geometries. In the second approach, you can only store the specified type of geometries as with ArcGIS and other systems.

3

I have three different type of geospatial data Road Direction, Pinpoint location with/without radius, Custom define area which I want to store.[...] The reason why should I store this in single column is to make it more flexible to add more data types later if needed and it would be easier to perform same actions on all of these in single query and some other relevant stuff

That doesn't make it more flexible. There is work to be done. You can do the work now, and maintain a tight schema which means querying it is fast and easy for the end-user and the database,

clean drawer

Or you can relax now, load up your stuff in to a heaping drunk drawer and delay the work until later, and deal with it every time you need something.

drunk drawer

The above is heterogeneous geometry column. It's certainly more flexible and less taxing on mental health and time to just do it right before you get to that point. Just put things where they belong, you won't regret it.

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.