Re: Storing data on a regular lat/lon grid - Mailing list pgsql-general

From Mike Charles
Subject Re: Storing data on a regular lat/lon grid
Date
Msg-id m2nbced44b41004141447y7ee6c2c1i54aaccf7ff7c5ca7@mail.gmail.com
Whole thread Raw
In response to Re: Storing data on a regular lat/lon grid  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-general
Basically, has anyone done any work with storing gridded spatial data? I see
lot's of info on Geospatial data, but it's usually cities, stations, etc.,
not a regular grid that doesn't change...

well, you could play around with storing information in arrays.
storing record for each point gives you the most flexibility of
querying and indexing but is extremely inefficient from storage
perspective.   arrays are better from that point of view and can work
pretty well as long as you read/write the data in blocks in a fairly
regular way (and hopefully the layout of your grid doesn't change that
often).

Thanks for your help, I've stored a 2-dimensional array in Postgres, inserted like this:

{{1,1,3},{2,2,1},{3,1,2}}

But I'm having trouble retrieving it from Java. My jdbc driver is loaded fine and I'm connecting to the database, but I don't know how to get from a java.sql Array to an int[] array in Java. I'm using this piece of code to pull the data from the ResultSet:

Array categoryArray = rs.getArray("category").getArray();

But I don't know what to do with this. I want to end up with an int[] array. Can anyone suggest something?

Thanks a lot,

--
Mike

pgsql-general by date:

Previous
From: Damian Carey
Date:
Subject: Re: pl/java status
Next
From: Bruce Momjian
Date:
Subject: Re: Unique cosntraint based on contents of a field?