[postgis-users] migrating tables to postgis

John Callahan john.callahan at udel.edu
Wed Jan 19 07:54:35 PST 2011


Thank you Etienne.  That may be the way to go.

The problem is that one table has the necessary attributes and another table
has the x,y coordinates.  They need to be separate tables.  Also, I'm using
EPSG:26918 (UTM Z18 meters).  Basic structures of both tables are:

Table1: StationID, easting, northing, elevation, owner, date (our complete
inventory table)
Table2: StationID, value1, value2, value3, etc...  (a data table with
observations)


Table2 gets updated on a more frequent basis, daily to weekly.  Table1 only
a few times per year.

Could I add a geom column to Table1 and then create a view that brings in
the data values I want to map?  I am not sure if packages such as QGIS,
MapServer, etc.., can read the view as a spatial class.  Or maybe create a
third table that brings in fields from Table1 and Table2, and then adds a
geom column?

- John

**************************************************
John Callahan, Research Scientist
Delaware Geological Survey, University of Delaware
URL: http://www.dgs.udel.edu
**************************************************


On Wed, Jan 19, 2011 at 10:28 AM, Etienne Bellemare <etiennebr at gmail.com>wrote:

> You should probably use something like this (let's say your coordinates are
> in the x and y columns [also replace <table> and <srid>]):
>
> SELECT AddGeometryColumn('<table> ','the_geom', <srid>,'POINT', 2);
> UPDATE <table>  SET the_geom = ST_SetSRID(ST_MakePoint(x,y), <srid>);
> --replace x and y if it's not the good columns
>
> For the view (you haven't provided much information), it depends of your
> table structure, if they are the same, if when you update one you're likely
> to update the other and if they aren't too big, then maybe it should be
> merged in a single table. Otherwise, a view could be usefull if you need to
> view these simultaneously.
>
> Etienne
>
>
> On Wed, Jan 19, 2011 at 9:30 AM, John Callahan <john.callahan at udel.edu>wrote:
>
>> Thanks Mark.  This gives me a direction to go.  I have the correct SRS,
>> and your other points are valuable.  ST_GeomFromText is really what I was
>> missing.  Thanks.
>>
>> The fact that I have two data tables to combine, would a View help here?
>> Or somehow modify the SELECT statements that would go into the
>> ST_GeomFromText function?  (the examples only show hard-coded coordinates
>> but I'm hoping a SELECT statement can provide input.)
>>
>> - John
>>
>>
>>
>> On Tue, Jan 18, 2011 at 4:20 PM, MarkW <mark.wimer at gmail.com> wrote:
>>
>>> Now that you have data in columns in Postgresql, you can use SQL
>>> statements to create your spatial data. Here are the steps:
>>> 1) identify your SRID/ spatial reference system
>>> 2) create geometries by passing your x and y with a spatial ref to the
>>> right function, and
>>> 3) add a row to the geometry_columns table so that other applications can
>>> more easily see the spatial data.
>>>
>>> 1) It's much easier if you can match your coordinate system to the right
>>> UTM srids in the spatial_ref_sys table; see spatialreference.org for
>>> help.
>>> 2) See this function:
>>> http://www.postgis.org/docs/ST_GeomFromText.html
>>> (and to prove it works, the reverse is ST_X or ST_Y) to get X,Y back out
>>> )
>>> 3)
>>> http://postgis.refractions.net/docs/ch04.html#Manual_Register_Spatial_Column
>>> (but also see the help under 'AddGeometryColumn (
>>> http://postgis.refractions.net/docs/AddGeometryColumn.html)
>>>
>>> Hope this helps.
>>>
>>> Mark
>>>
>>>
>>> On Tue, Jan 18, 2011 at 3:37 PM, John Callahan <john.callahan at udel.edu>wrote:
>>>
>>>> I apologize for asking what seems like an easy question.   I'm really
>>>> just getting started with PostGIS and not sure which way to go here.   I
>>>> have a two tables in MS Access format.  They are:
>>>>
>>>> Table1: StationID, easting, northing, elevation, etc...
>>>> Table2: StationID, data values...
>>>>
>>>> Table1 is basically an inventory of all our stations.  Table2 is a
>>>> subset that includes only stations we have certain data for.   How would I
>>>> convert these into a point data set (of Table2 stations) in PostGIS?   I was
>>>> able to copy the tables from Access into Postgres. Where would I go from
>>>> here?    Maybe OGR would help going directly from Access (or text exports of
>>>> Access) into PostGIS?
>>>>
>>>> I am using Postgres 9.0.2/PostGIS 2.0.0 on Windows, and using Quantum
>>>> GIS for viewing.  Thanks for any guidance.
>>>>
>>>> - John
>>>>
>>>> **************************************************
>>>> John Callahan, Research Scientist
>>>> Delaware Geological Survey, University of Delaware
>>>> URL: http://www.dgs.udel.edu
>>>> **************************************************
>>>>
>>>>
>>> _______________________________________________
>>> postgis-users mailing list
>>> postgis-users at postgis.refractions.net
>>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>>
>>>
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
>>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20110119/708be3d7/attachment.html>


More information about the postgis-users mailing list