[postgis-users] unique id in QGIS/PostGIS

Margie Roswell mroswell at gmail.com
Sat Apr 6 01:18:59 PDT 2013


I've been googling up a storm, now that I've got a local postgis database
with QGIS. But still haven't figured out how to display a newly created
table.

The query I used to create the table:
CREATE TABLE smaller_leg_final AS
SELECT ST_Buffer(geom,-500) AS geom, legislative_final.district
FROM legislative_final
WHERE area > 30;

I then discovered that I needed a unique ID, and did the following:
ALTER TABLE smaller_leg_final ADD COLUMN id serial not null;

This successfully populated the ID field with unique integers.

However when I go into QGIS, the Primary Key column offers no options. when
I click into it, it just asks me to choose an SRID, which I believe I've
already done. The table loads, but nothing displays.

I honestly feel a bit like a toddler given ice skates and placed on an icy
rink. I'm toddling my way around, falling, getting back up, and then
looking up and asking: why did I fall?

Once upon a time I was at the true cutting edge of GIS... I purchased
MapInfo versions 1.1, and upgraded from there for many years. Moving into
QGIS/Posgres/postGIS now, and well on the path to success, but .... not...
quite... there.

Are there any QGIS users here who can help me to display my new table?

Do I need a different postgres statement? Is there a different field name
expected? Maybe my query generated invalid shapes... But still, the geom
field is displaying in the "Add PostGIS layers "Geometry column", but the
Primary key column option doesn't allow me to select my 'id' field.

Insight welcome.




--
http://FarmBillPrimer.org
http://www.BaltimoreUrbanAg.org (Please send events; This site is hungry.)
http://www.ExcellentNutrition.org
http://www.packtpub.com/drupal-5-views-recipes/book


On Thu, Apr 4, 2013 at 11:21 AM, Lelo - Luiz Rogério De Pieri <
lelo.pieri at gmail.com> wrote:

> Hi all,
>
> I'm having a problem to execute a pgsql2shp command using java.
>
> My OS is Ubuntu and it's frequently I use to generate shp files using
> pgsql2shp, but now I want to do it through java.
>
> The follow command works fine on terminal
> pgsql2shp -f pontos_05600202_teste -h myhost -u myuser -P mypasswd -g
> coordinates my_database "SELECT * from points where id_uploaded_file =
> 37995";
>
> Now I'm trying to execute the follow code:
>
> ProcessBuilder pb = new ProcessBuilder("pgsql2shp", "-f
> pontos_05600202_teste", "-h myhost", "-u myuser", "-P mypasswd", "-g
> coordinates", "my_database", "SELECT coordinates, date from points where
> id_uploaded_file = 37995");
>
> Process proc;
> proc = pb.start();
> InputStream stdin = proc.getInputStream();
> InputStreamReader isr = new InputStreamReader(stdin);
> BufferedReader br = new BufferedReader(isr);
>
> String line = null;
> System.out.println("<OUTPUT>");
>
> while ((line = br.readLine()) != null)
>     System.out.println(line);
>
> System.out.println("</OUTPUT>");
> int exitVal = proc.waitFor();
> System.out.println("Process exitValue: " + exitVal);
>
>
> And the result is:
>
> <OUTPUT>
> Preparing table for user query... Done.
> Initializing...  coordinates: no such attribute in table
> __pgsql2shp14493_tmp_table
> </OUTPUT>
>
> Does anybody as any idea about it?
>
> Thank you for all
>
> Best regards
> --
> Rogério De Pieri  (Lelo)
> SCJP 5
> Buscando melhorar a cada dia
> Áudio, Hardware & Software
> www.twitter.com/lelopieri
> blogdolelo.wordpress.com
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20130406/b5cf6410/attachment.html>


More information about the postgis-users mailing list