<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">HI Margie,<br><br>I gave up on Windows as a productive computing environment last century, & have zero regrets about that these days, so I'm not the best person to offer Windows oriented help... however...<br><br>There are three ways to run scripts under Windows - Y<br><br>1. You can install Cygwin - which gives you a Linux-like environment within Windows, but is somewhat complicated & arcane. This does allow you to run the exact same bash scripts under Windows & Linux.<br><br>2. You can install Windows powershell & write your scripts using that "language":<br><a href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx">http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx</a><br><br>3. You can write your scripts as batch files. Batch files are pretty limited, without text processing & other capabilities, but are probably
able to do what you are looking to do right now. All Windows systems can run batch files with no additional software installed.<br> <br>So, I'd suggest you look at batch files initially.<br><br>Google "batch file tutorial" & there are plenty to choose from, like <a href="http://www.chebucto.ns.ca/~ak621/DOS/BatBasic.html">http://www.chebucto.ns.ca/~ak621/DOS/BatBasic.html</a><br><br> If you open a terminal window & type "psql -l" then press enter, you'll know if your path is already set up as they need to be. This is probably the only tricky thing you might need to configure. If it works, great, if not you'll need to add the folder containing the psql command to your path. If you do need to do this, see: <br><a href="http://www.computerhope.com/issues/ch000549.htm">http://www.computerhope.com/issues/ch000549.htm</a><br>but it should be unecessary.<br><br>The simple shell script as a batch file - if I remember correctly
:-)<br>__________________________________________________________<br>REM script to load Legislative_shape.zip & create unique index<br><br>SHP=Legislative_final_shapefile\Legislative_Final.shp<br><br>REM create new, empty Postgres database<br>dropdb test<br>createdb test<br><br>REM install postgis<br>psql -d test -c "create extension postgis;"<br><br>REM determine projection <br>REM assume from these links that the SRID is 3559 -<br>REM I couldn't find one to match the prj file directly<br>REM http://planning.maryland.gov/msdc/S5_Map_GIS.shtml<br>REM http://www.spatialreference.org/ref/sr-org/3559/<br><br>REM load the shapefile the easy way...<br>shp2pgsql -s 3559 -I %SHP% legislative_final | psql -d test<br>___________________________________________________________<br><br><br>Cheers,<br><br> Brent<br>--- On <b>Mon, 4/8/13, Margie Roswell <i><mroswell@gmail.com></i></b> wrote:<br><blockquote style="border-left: 2px solid
rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Margie Roswell <mroswell@gmail.com><br>Subject: Re: [postgis-users] unique id in QGIS/PostGIS<br>To: pcreso@pcreso.com<br>Cc: "PostGIS Users Discussion" <postgis-users@lists.osgeo.org><br>Date: Monday, April 8, 2013, 2:45 AM<br><br><div id="yiv612757614">One step at a time. I figured out how to set the path in windows, to access psql <div><br></div><div>So, next, to try to figure out how to script... (on the windows side)</div><div><br></div><div>inching forward,</div><div>
<br></div><div>Margie</div><div><br clear="all"><div><div>--</div><div><a rel="nofollow" target="_blank" href="http://FarmBillPrimer.org">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.BaltimoreUrbanAg.org">http://www.BaltimoreUrbanAg.org</a> (Please send events; This site is hungry.)<br>
<a rel="nofollow" target="_blank" href="http://www.ExcellentNutrition.org">http://www.ExcellentNutrition.org</a><br><a rel="nofollow" target="_blank" href="http://www.packtpub.com/drupal-5-views-recipes/book">http://www.packtpub.com/drupal-5-views-recipes/book</a><br>
</div>
<br><br><div class="yiv612757614gmail_quote">On Sun, Apr 7, 2013 at 10:35 AM, Margie Roswell <span dir="ltr"><<a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="/mc/compose?to=mroswell@gmail.com">mroswell@gmail.com</a>></span> wrote:<br><blockquote class="yiv612757614gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks very much. I like the idea of scripting these routine behaviors.<br><br>1. I figured out that the correct CRS is <br><a rel="nofollow" target="_blank" href="http://spatialreference.org/ref/epsg/4019/">http://spatialreference.org/ref/epsg/4019/</a><br>
<br>It basically says (in QGIS) <br>Unknown datum based upon the GRS 1980 ellipsoid EPSG:4019<br>but it does exactly match the PRJ file for legislative_final shapefile.<br><br>A friend suggests using Maryland State Plan, so, I'll likely switch that command to <br>
<br>shp2pgsql -s 3559:26985 -I $SHP legislative_final | psql -d test<br><br>2. I do have access to a PostGIS install on a mac or an EC2, but right now my preferred environment is windows, with my large screen, and special wrist-friendly keyboard.<b> So, I'm going to have to figure out how to run this script.</b> (or even how run anything from the command line on the windows side.)<br>
<br>If anyone has some insight into how to run or replicate a bash script on a windows installation, let me know. The<b> psql tool that comes with windows starts right inside a database</b>, so I haven't actually yet figured out how to even run a simple postgres command on the windows side. No success from either the SQL shell or the regular windows command prompt.<br>
<div><br>The scripting approach:</div><div>- offers helpful comments to remind us of the data source. </div><div>- offers a record of exactly what we did. (Part of the reason I've been using PgAdmin III is that I have appreciated the history file there.)<br>
<br>Since I like this scripting approach, I'm off to try to figure out how to do it on the windows side.... Is anyone here running postgres on windows, with command line success?</div><span class="yiv612757614HOEnZb"><font color="#888888"><div>
<br></div></font></span><div><span class="yiv612757614HOEnZb"><font color="#888888">Margie</font></span><div class="yiv612757614im"><br><br clear="all">
<div><div>--</div><div><a rel="nofollow" target="_blank" href="http://FarmBillPrimer.org">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.BaltimoreUrbanAg.org">http://www.BaltimoreUrbanAg.org</a> (Please send events; This site is hungry.)<br>
<a rel="nofollow" target="_blank" href="http://www.ExcellentNutrition.org">http://www.ExcellentNutrition.org</a><br><a rel="nofollow" target="_blank" href="http://www.packtpub.com/drupal-5-views-recipes/book">http://www.packtpub.com/drupal-5-views-recipes/book</a><br>
</div>
<br><br></div><div><div class="yiv612757614h5"><div class="yiv612757614gmail_quote">On Sat, Apr 6, 2013 at 6:37 PM, <span dir="ltr"><<a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="/mc/compose?to=pcreso@pcreso.com">pcreso@pcreso.com</a>></span> wrote:<br><blockquote class="yiv612757614gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font:inherit;" valign="top">Hi again,<br><br>In your screencap your SRID seems to be set to zero. Even if the data displays in QGIS, it will not be in the correct place, unless you have this set correctly. So with the unique index/prikary key - you still probably won't see the data unless you zoom the that layer extent.<br>
<br>I have scribbled out a quick Linux script which uses the shp2pgsql command to load the shapefile, & which creates the unique index automatically... I'm not certain I got the SRID correct - so it will be worth checking.<br>
<br>HTH,<br><br> Brent Wood<br><br><br>#! /bin/bash<br># script to load Legislative_shape.zip & create unique index<br><br>SHP=Legislative_final_shapefile/Legislative_Final.shp<br><br># create new, empty Postgres database<br>
dropdb test<br>createdb test<br><br># install postgis<br>psql -d test -c "create extension postgis;"<br><br>#
determine projection <br># assume from these links that the SRID is 3559 -<br># I couldn't find one to match the prj file directly<br># <a rel="nofollow" target="_blank" href="http://planning.maryland.gov/msdc/S5_Map_GIS.shtml">http://planning.maryland.gov/msdc/S5_Map_GIS.shtml</a><br>
# <a rel="nofollow" target="_blank" href="http://www.spatialreference.org/ref/sr-org/3559/">http://www.spatialreference.org/ref/sr-org/3559/</a><br><br># load the shapefile the easy way...<br># use -I to create the primary key<br>shp2pgsql -s 3559 -I $SHP legislative_final | psql -d test<div>
<br><br>--- On <b>Sat, 4/6/13, Margie Roswell <i><<a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="/mc/compose?to=mroswell@gmail.com">mroswell@gmail.com</a>></i></b> wrote:<br></div><blockquote style="border-left:2px solid rgb(16,16,255);margin-left:5px;padding-left:5px;">
<div><br>From: Margie Roswell <<a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="/mc/compose?to=mroswell@gmail.com">mroswell@gmail.com</a>><br>Subject: [postgis-users] unique id in QGIS/PostGIS<br>To: "PostGIS Users Discussion" <<a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="/mc/compose?to=postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>><br>
Date: Saturday, April 6, 2013, 9:18 PM<br><br></div><div><div><div>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. <br><br>The query I used to create the table:<br><div style="margin-left:40px;">
CREATE TABLE smaller_leg_final AS<br>SELECT ST_Buffer(geom,-500) AS geom, legislative_final.district<br>FROM legislative_final<br>WHERE area > 30;<br></div><br>I then discovered that I needed a unique ID, and did the following:<br>
<div style="margin-left:40px;">ALTER TABLE smaller_leg_final ADD COLUMN id serial not null;<br></div><br>This successfully populated the ID field with unique integers.<br><br>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. <br>
<br>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?<br><br>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.<br>
<br>Are there any QGIS users here who can help me to display my new table?<br><br>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.<br>
<br>Insight welcome.<br><br><br><br><br clear="all"><div><div>--</div><div><a rel="nofollow" target="_blank" href="http://FarmBillPrimer.org">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.BaltimoreUrbanAg.org">http://www.BaltimoreUrbanAg.org</a> (Please send events; This site is hungry.)<br>
<a rel="nofollow" target="_blank" href="http://www.ExcellentNutrition.org">http://www.ExcellentNutrition.org</a><br><a rel="nofollow" target="_blank" href="http://www.packtpub.com/drupal-5-views-recipes/book">http://www.packtpub.com/drupal-5-views-recipes/book</a><br>
</div>
<br><br><div>On Thu, Apr 4, 2013 at 11:21 AM, Lelo - Luiz Rogério De Pieri <span dir="ltr"><<a rel="nofollow" target="_blank" href="http://mc/compose?to=lelo.pieri@gmail.com">lelo.pieri@gmail.com</a>></span> wrote:<br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr"><div><div><div>Hi all,<br><br></div>I'm having a problem to execute a pgsql2shp command using java.<br><br></div>My OS is Ubuntu and it's frequently I use to generate shp files using pgsql2shp, but now I want to do it <span lang="en"><span>through java.<br>
<br></span></span></div><div><span lang="en"><span>The follow command works fine on terminal<br>pgsql2shp -f pontos_05600202_teste -h myhost -u myuser -P mypasswd -g coordinates my_database "SELECT * from points where id_uploaded_file = 37995";<br>
<br></span></span></div><div><span lang="en"><span>Now I'm trying to execute the follow code:<br><br><span style="font-family:courier new, monospace;">ProcessBuilder pb = new ProcessBuilder("pgsql2shp", "-f pontos_05600202_teste", "-h myhost", "-u myuser", "-P mypasswd", "-g </span></span></span><span lang="en"><span><span style="font-family:courier new, monospace;"><span lang="en"><span><span style="font-family:courier new, monospace;">coordinates</span></span></span>", "my_database", "SELECT coordinates, date from points where id_uploaded_file = 37995");<br>
<br>Process proc;<br>proc = pb.start();<br>InputStream stdin = proc.getInputStream();<br>InputStreamReader isr = new InputStreamReader(stdin);<br>BufferedReader br = new BufferedReader(isr);<br><br>String line = null;<br>
System.out.println("<OUTPUT>");<br><br>while ((line = br.readLine()) != null)<br> System.out.println(line);<br><br>System.out.println("</OUTPUT>");<br>int exitVal = proc.waitFor();<br>System.out.println("Process exitValue: " + exitVal);</span><br>
</span></span></div><div><br clear="all"><div><div><div><div><div><div><div><div><br></div><div>And the result is:<br><br><span style="font-family:courier new, monospace;"><OUTPUT><br>Preparing table for user query... Done.<br>
Initializing... </span><span style="font-family:courier new, monospace;"><span lang="en"><span><span style="font-family:courier new, monospace;">coordinates</span></span></span>: no such attribute in table __pgsql2shp14493_tmp_table<br>
</OUTPUT></span><br><br></div><div>Does anybody as any idea about it?<br><br></div><div>Thank you for all<br><br>Best regards<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div>
-- <br>Rogério De Pieri (Lelo)<div>SCJP 5<br><div><div>Buscando melhorar a cada dia<br>
Áudio, Hardware & Software</div></div><div><a rel="nofollow" target="_blank" href="http://www.twitter.com/lelopieri">www.twitter.com/lelopieri</a></div><div><a rel="nofollow" target="_blank" href="http://blogdolelo.wordpress.com">blogdolelo.wordpress.com</a></div>
</div>
</div></font></span></div></div></div></div></div></div></div></div></div>
<br>_______________________________________________<br>
postgis-users mailing list<br>
<a rel="nofollow" target="_blank" href="http://mc/compose?to=postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a rel="nofollow" target="_blank" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br>
<br></blockquote></div><br>
</div><br></div></div>-----Inline Attachment Follows-----<div><br><br><div>_______________________________________________<br>postgis-users mailing list<br><a rel="nofollow" target="_blank" href="http://mc/compose?to=postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a rel="nofollow" target="_blank" href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br></div></div></blockquote></td></tr></tbody></table></blockquote>
</div><br>
</div></div></div>
</blockquote></div><br></div>
</div></blockquote></td></tr></table>