[postgis-users] Beginning in PostGIS
James Keener
jim at jimkeener.com
Sat Apr 18 11:11:12 PDT 2015
OH, I think I understand: You want to copy and paste from a shapefile
layer into the appropriate postgis layer?
I don't know if you can do that directly. You may want to write a
script to do it, or import the shapefile into a temporary table and then
using multiple sql statements to build up your normalized tables.
http://stackoverflow.com/questions/1310103/split-table-with-duplicates-into-2-normalized-tables
has a little example. Basically you import the towns with a insert into
blah select distinct (town code, town description) and then continue
that, but for the foreign keys have your updates or inserts do a
subquery to find the correct foreign row.
Jim
On 04/18/2015 02:01 PM, Luciano wrote:
> Ok,
>
> I have a shape file with the following structure.
>
> Shape file, columns:
> town code;
> town description;
> Neighborhood code;
> name of the neighborhood;
> block code;
> Street code;
> street name;
>
> Using the How to Copy / paste a geometry fromshape file to postgiswith
> follow structure:
>
> Cities table (data):
> - Town id
> - Description of town
>
> Neighborhoods table (data):
> - Id of the neighborhood
> - Description of the neighborhood
> - Id of town (foreign key)
>
> Blocks table:
> - Id of the court
> - Block of code
> - Town id (foreign key)
> - Geometry, polygon
>
> Streets table:
> - Street id
> - Street name
> - Town id (foreign key)
> - Geometry, line
>
>
>
> 2015-04-18 13:36 GMT-03:00 Rémi Cura <remi.cura at gmail.com
> <mailto:remi.cura at gmail.com>>:
>
> maintaining your data model is easy to do with triggers.
>
> About copy / past.
> Sorry this just doesn't make much sense to me.
>
> You can import shapefile into postgres if it is the question.
> You can also use trigger on the import table to fill you rmodel with
> the imported data.
>
> Cheers,
> Rémi-C
>
> 2015-04-18 17:39 GMT+02:00 Luciano <br.analistagis at gmail.com
> <mailto:br.analistagis at gmail.com>>:
>
>
> Hi,
> I wonder how can I update a postgresql postgis database before
> the following scenario:
> Always worked with shape files and update them used copy / paste
> between files.
> Now, think about creating a database in PostgreSQL and would
> like to continue using copy / paste to update polygons, but in
> my database structure is different from the shape file. For example:
> Imagine that the shapefile have all the fields in one table,
> already in the database, by reason of standardization, have
> these columns in tables
> distinct. Below is an example of a register of towns.
>
> File shape, columns:
> town code;
> town description;
> Neighborhood code;
> name of the neighborhood;
> block code;
> Street code;
> street name;
>
> In Postgres / Gis could look like this:
>
> Cities table (data):
> - Town id
> - Description of town
>
> Neighborhoods table (data):
> - Id of the neighborhood
> - Description of the neighborhood
> - Id of town (foreign key)
>
> Blocks table:
> - Id of the court
> - Block of code
> - Town id (foreign key)
> - Geometry, polygon
>
> Streets table:
> - Street id
> - Street name
> - Town id (foreign key)
> - Geometry, line
>
> How could update (insert) a block in postgresql table using copy
> / paste the shape file?
> Would have to create a trigger/procedure (instead of) to
> automate the process?
> Fields of shape file should be equal to the fields of database
> table?
> Some practical example as a reference?
>
> tia
> --
> Luciano
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org <mailto:postgis-users at lists.osgeo.org>
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
>
>
> --
> Luciano
>
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150418/55e1b1eb/attachment.pgp>
More information about the postgis-users
mailing list