<html><body><div style="color:#000; background-color:#fff; font-family:tahoma, new york, times, serif;font-size:10pt">Margie --<br><br>What does the postgres log say b? <br><br>If it showsnothing the attempt to connect never made it to the postgres port (usually 5432 but I don't inow what Windows might be using for a local connection).<br><br>If it did make the basix handshake, the log message might show an authentication issue or other useful tidbit.<br><span class="tab"></span><div><span><br></span></div><div>People with more windows experience might tell you where to look for the log and what to tweak on the config side to allow connections locally.</div><div><br></div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: tahoma,new york,times,serif; background-color: transparent; font-style: normal;">Greg Williamson</div><div style="color: rgb(0, 0, 0); font-size: 13.3333px; font-family: tahoma,new york,times,serif; background-color:
transparent; font-style: normal;"><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; margin-top: 5px; padding-left: 5px;"> <div style="font-family: tahoma, new york, times, serif; font-size: 10pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1"> <b><span style="font-weight:bold;">From:</span></b> Margie Roswell <mroswell@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> PostGIS Users Discussion <postgis-users@lists.osgeo.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Monday, April 8, 2013 7:27 PM<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [postgis-users] unique id in QGIS/PostGIS<br> </font> </div> <br><div id="yiv194868961"><div><br></div>This thread morphed from a QGIS issue to a configuration and scripting and environment issue. I'm fine with that... if I get
a comfortable working environment, I'll be ready to tackle other learning curves... so now I'll report my struggles on this "environment" front.<div>
<br></div><div>First, I might mention that I'm actually generally competent in a linux environment. Command line, no problem. And usually I can routinely edit files in vim, for instance, but I'll have to figure out a slew of key bindings to make vim remotely usable now that I'm in windows Not a problem, I've got Sublime Text 2. So, ignoring that issue the need-sensible vim-key-bindings issue for now.</div>
<div><br></div><div>I'm choosing windows because it's where my comfortable keyboard is, my large monitor, my desk. Little macbook laptop can't compete on this front. (I'll consider another system, if I totally strike out on the windows side... but hoping for one desk, one desktop.)</div>
<div><br></div><div>Biggest issue now is basically 'hello world'. My GUI interface was working... but now on the Cygwin side, I've got this. (I'm copying from the postgres documentation, because the error matches:</div>
<div><br></div><div><pre style="font-size:12px;border:1px solid rgb(207,207,207);padding:2ex;margin-top:2ex;margin-bottom:2ex;margin-left:2ex;overflow:auto;background-color:rgb(247,247,247);">
createdb: could not connect to database template1: could not connect to server:
No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
</pre><div style="line-height:1.5em;font-size:12px;font-family:verdana, sans-serif;margin:1.2em 0em;">This means that the server was not started, or it was not started where <tt style="font-size:1.2em;">createdb</tt> expected it. Again, check the installation instructions or consult the administrator.</div>
</div><div>----------------------------------</div><div><div><div>So, I'm really at ground zero on the cygwin side of things. </div><div>I've got ;C:\Program Files\PostgreSQL\9.2\bin in my path. So, I'm not sure how to start the server.</div>
<div><br></div><div>And I've also added to bash path (without success here) </div><div><a rel="nofollow" target="_blank" href="http://stackoverflow.com/questions/4918830/how-can-i-set-my-cygwin-path-to-find-javac">http://stackoverflow.com/questions/4918830/how-can-i-set-my-cygwin-path-to-find-javac</a></div>
<div><br></div><div><div>owner@owner-PC ~/src</div><div>$ export PATH=$PATH:/cygdrive/c/Program\ Files/PostgreSQL/9.2/bin</div><div><br></div><div>owner@owner-PC ~/src</div><div>$ $PATH</div><div>-bash: /usr/local/bin:/cygdrive/c/Program: No such file or directory</div>
</div><div><br></div><div>and lots of variations.</div>
<div><br></div>
<div><br></div><div>Sorry, so long. This is just all an earnest way of asking: what do I do to get past the </div><div><pre style="font-size:12px;border:1px solid rgb(207,207,207);padding:2ex;margin-top:2ex;margin-bottom:2ex;margin-left:2ex;overflow:auto;background-color:rgb(247,247,247);">
createdb: could not connect to database template1: could not connect to server:
No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?</pre></div><div>error?</div><div><br></div><div>Margie</div><div><br></div><div>P.S. </div><div><br></div><div>My goal was to place random dots, in legislative districts, 1, 2, or 3, as appropriate. No problem, QGIS makes that easy. But basically I wanted an internal buffer for each district shape, because I didn't like how close to the edge those dots were appearing. and that's when my trouble began. despite an accurate buffer statement, the map refused to show. So, a few days ago, I was on a far more advanced part of the learning curve, and now, trying to get an environment that'll run a script... or even just run ANY postgres command. </div>
<div><br></div><div><br></div><div><br></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="yiv194868961gmail_quote">On Sun, Apr 7, 2013 at 8:39 PM, Stephen Mather <span dir="ltr"><<a rel="nofollow" ymailto="mailto:mather.stephen@gmail.com" target="_blank" href="mailto:mather.stephen@gmail.com">mather.stephen@gmail.com</a>></span> wrote:<br><blockquote class="yiv194868961gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr"><div><div><div>I would add to this that you can put different shapefiles into different tables:<br><br><span style="font-family:courier new, monospace;">for /r %%z in (*.dbf) do (%SHP2PGSQL% -s 4326 -g geom -W "latin1" %%z %%~nz | %PSQL% )</span><br>
<br></div>where <i>%~nz</i> becomes the output tablename based on the name without extension of the input shapefile.<br><br></div>Also, if you don't want to run this as a batch file, but just run it on the command line, use a single percent:<br>
<br><span style="font-family:courier new, monospace;">for /r %z in (*.dbf) do (%SHP2PGSQL% -s 4326 -g geom -W "latin1" %z %~nz | %PSQL% )</span><br><br><br></div><div>If you are interested in using PowerShell for this, it looks something like this:<br>
<div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$shapefile
= dir *.<font>shp</font></font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$x
= 0</font></span></div><span style="font-family:courier new, monospace;"><br>
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$<font>shap</font>efile
|foreach {</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">write-host
($x++) "of $($<font>shap</font>efile.count) is started. $($_.Name) is processing"</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">write-host
"<font>sh<font>p2pgsql -s 4326 -g geom -W <font>latin1</font></font></font> $($_.name)
$($_.basename) | psql"</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">}</font></span></div><br></div><div>I often write out all the flags I need for psql, so it might look more like this:<br>
<div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$shapefile
= dir *.<font>shp</font></font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$x
= 0</font></span></div><span style="font-family:courier new, monospace;"><br>
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"><span style="font-family:courier new, monospace;"><font style="font-size:9pt;">$<font>shap</font>efile
|foreach {</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">write-host
($x++) "of $($<font>shap</font>efile.count) is started. $($_.Name) is processing"</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">write-host
"<font>sh<font>p2pgsql -s 4326 -g geom -W <font>latin1</font></font></font> $($_.name)
$($_.basename) | psql -U <font>postgres -d databasena<font>me -h localhost -p 5432</font></font>"</font></span></div><span style="font-family:courier new, monospace;">
</span><div style="margin-left:0.25in;margin-bottom:0.03in;"> <span style="font-family:courier new, monospace;"><font style="font-size:9pt;">}</font></span></div><br><br></div><div><br></div>Best,<br>Steve<br><div><br><br><div>
<div><br><div><br><br></div></div></div></div></div><div><div><div class="yiv194868961gmail_extra"><br><br><div class="yiv194868961gmail_quote">On Sun, Apr 7, 2013 at 6:41 PM, Paragon Corporation <span dir="ltr"><<a rel="nofollow" ymailto="mailto:lr@pcorp.us" target="_blank" href="mailto:lr@pcorp.us">lr@pcorp.us</a>></span> wrote:<br>
<blockquote class="yiv194868961gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><u></u>
<div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>Slight correction forgot the )</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span><span><font color="#0000ff" face="Arial">for /r %%z in (*.dbf) do (%SHP2PGSQL% -s 4326 -g
geom -W "latin1" %%z sometable | %PSQL% )</font></span></span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span><span></span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span><span>You can also chain
commands by using &</span></span></font><font color="#0000ff" face="Arial"><span><span></span></span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span><span><font color="#0000ff" face="Arial">for /r %%z in (*.dbf) do (%SHP2PGSQL% -s 4326 -g
geom -W "latin1" %%z sometable | %PSQL% & %PSQL% -c "SELECT
postgis_full_version()" )</font></span></span></font><br></div>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> <a rel="nofollow" ymailto="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank" href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>
[mailto:<a rel="nofollow" ymailto="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank" href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Paragon
Corporation<br><b>Sent:</b> Sunday, April 07, 2013 6:38 PM<br><b>To:</b>
'PostGIS Users Discussion'<div><div><br><b>Subject:</b> Re: [postgis-users] unique id in
QGIS/PostGIS<br></div></div></font><br></div><div><div>
<div></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>You can also use msys mingw. We use the mingw64
chain which allows you to run linux shell scripts. That's what we use to
compile PostGIS for windows.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>That aside, probably for what you want to do for
starters as Brent suggested, batch scripts are sufficient.</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span>Our general batch script for loading up shape files
looks something like this:</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div><span>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial">set
PGBIN=C:\Program Files\PostgreSQL\9.2\bin\<br>set PGPORT=5432<br>set
PGHOST=localhost<br>set PGUSER=postgres<br>set PGPASSWORD=something</font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial">set
PGDATABASE=<span>mygisdb</span></font></div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span>set PSQL="%PGBIN%psql"<br>set
SHP2PGSQL="%PGBIN%shp2pgsql"</font></div></span></div></div></div><div><div>
<div dir="ltr" align="left"><font color="#0000ff" face="Arial"><span></span></font> </div>
<div><font color="#0000ff" face="Arial">%SHP2PGSQL% -c -s <span>4326 </span> -g geom -W
"latin1" <span>somefile.shp</span> <span>sometable</span> | %PSQL%</font></div>
<div><font color="#0000ff" face="Arial"></font> </div>
<div><span><font color="#0000ff" face="Arial">If you
need to load up a whole bunch of files in a table you can use the for do
batch command</font></span></div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div><span><font color="#0000ff" face="Arial">for /r
%%z in (*.dbf) do (%SHP2PGSQL% -s 4326 -g geom -W "latin1" %%z
sometable | %PSQL% </font></span></div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div><font color="#0000ff" face="Arial"><span></span></font> </div>
<div><span><font color="#0000ff" face="Arial">Hope
that helps,</font></span></div>
<div><span><font color="#0000ff" face="Arial">Leo
and Regina</font></span></div>
<div><span><font color="#0000ff" face="Arial"><a rel="nofollow" target="_blank" href="http://www.postgis.us/">http://www.postgis.us</a></font></span></div>
<div><span><font color="#0000ff" face="Arial"><a rel="nofollow" target="_blank" href="http://postgis.net/">http://postgis.net</a></font></span></div>
<div><span></span> </div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div><span><font color="#0000ff" face="Arial"></font></span> </div>
<div><br></div>
<div dir="ltr" align="left" lang="en-us">
<hr>
<font face="Tahoma"><b>From:</b> <a rel="nofollow" ymailto="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank" href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>
[mailto:<a rel="nofollow" ymailto="mailto:postgis-users-bounces@lists.osgeo.org" target="_blank" href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Marjorie
Roswell<br><b>Sent:</b> Sunday, April 07, 2013 2:37 PM<br><b>To:</b>
<a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a><br><b>Cc:</b> <a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br><b>Subject:</b>
Re: [postgis-users] unique id in QGIS/PostGIS<br></font><br></div>
<div></div>
<div>Thanks immensely. Some years ago on a different computer, I installed
cygwin. Great reminder, and I appreciate it. I'll be back at my
computer this evening. <br><br>Sent from my iPhone</div>
<div><br>On Apr 7, 2013, at 2:11 PM, <a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a> wrote:<br><br></div>
<div></div>
<blockquote type="cite">
<div>
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="top">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 rel="nofollow" target="_blank" href="http://technet.microsoft.com/en-us/scriptcenter/dd742419.aspx"></a><a rel="nofollow" target="_blank" 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 rel="nofollow" target="_blank" href="http://www.chebucto.ns.ca/~ak621/DOS/BatBasic.html"></a><a rel="nofollow" target="_blank" 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 rel="nofollow" target="_blank" href="http://www.computerhope.com/issues/ch000549.htm"></a><a rel="nofollow" target="_blank" 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 <a rel="nofollow" target="_blank" href="http://planning.maryland.gov/msdc/S5_Map_GIS.shtml"></a><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>
REM
<a rel="nofollow" target="_blank" href="http://www.spatialreference.org/ref/sr-org/3559/"></a><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>
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><<a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="mailto:mroswell@gmail.com">mroswell@gmail.com</a>></i></b>
wrote:<br>
<blockquote style="PADDING-LEFT:5px;MARGIN-LEFT:5px;BORDER-LEFT:rgb(16,16,255) 2px solid;"><br>From:
Margie Roswell <<a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="mailto:mroswell@gmail.com">mroswell@gmail.com</a>><br>Subject:
Re: [postgis-users] unique id in QGIS/PostGIS<br>To: <a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="mailto:pcreso@pcreso.com"></a><a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a><br>Cc:
"PostGIS Users Discussion" <<a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>><br>Date:
Monday, April 8, 2013, 2:45 AM<br><br>
<div>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/"></a><a rel="nofollow" target="_blank" href="http://farmbillprimer.org/">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.baltimoreurbanag.org/"></a><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/"></a><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"></a><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 Sun, Apr 7, 2013 at 10:35 AM,
Margie Roswell <span dir="ltr"><<a rel="nofollow" target="_blank" href="http://mc/compose?to=mroswell@gmail.com"></a><a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="mailto:mroswell@gmail.com">mroswell@gmail.com</a>></span>
wrote:<br>
<blockquote style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid;">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/"></a><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><font color="#888888">
<div><br></div></font></span>
<div><span><font color="#888888">Margie</font></span>
<div><br><br clear="all">
<div>
<div>--</div>
<div><a rel="nofollow" target="_blank" href="http://farmbillprimer.org/"></a><a rel="nofollow" target="_blank" href="http://farmbillprimer.org/">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.baltimoreurbanag.org/"></a><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/"></a><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"></a><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>
<div>On Sat, Apr 6, 2013 at 6:37 PM,
<span dir="ltr"><<a rel="nofollow" target="_blank" href="http://mc/compose?to=pcreso@pcreso.com"></a><a rel="nofollow" ymailto="mailto:pcreso@pcreso.com" target="_blank" href="mailto:pcreso@pcreso.com">pcreso@pcreso.com</a>></span>
wrote:<br>
<blockquote style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid;">
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td 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"></a><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/"></a><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" target="_blank" href="http://mc/compose?to=mroswell@gmail.com"></a><a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="mailto:mroswell@gmail.com">mroswell@gmail.com</a>></i></b>
wrote:<br></div>
<blockquote style="PADDING-LEFT:5px;MARGIN-LEFT:5px;BORDER-LEFT:rgb(16,16,255) 2px solid;">
<div><br>From: Margie Roswell <<a rel="nofollow" target="_blank" href="http://mc/compose?to=mroswell@gmail.com"></a><a rel="nofollow" ymailto="mailto:mroswell@gmail.com" target="_blank" href="mailto:mroswell@gmail.com">mroswell@gmail.com</a>><br>
Subject:
[postgis-users] unique id in QGIS/PostGIS<br>To: "PostGIS
Users Discussion" <<a rel="nofollow" target="_blank" href="http://mc/compose?to=postgis-users@lists.osgeo.org"></a><a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto: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/"></a><a rel="nofollow" target="_blank" href="http://farmbillprimer.org/">http://FarmBillPrimer.org</a></div><a rel="nofollow" target="_blank" href="http://www.baltimoreurbanag.org/"></a><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/"></a><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"></a><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"></a><a rel="nofollow" ymailto="mailto:lelo.pieri@gmail.com" target="_blank" href="mailto:lelo.pieri@gmail.com">lelo.pieri@gmail.com</a>></span>
wrote:<br>
<blockquote style="PADDING-LEFT:1ex;MARGIN:0px 0px 0px 0.8ex;BORDER-LEFT:#ccc 1px solid;">
<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"></a><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/"></a><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"></a><a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto: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"></a><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"></a><a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto: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"></a><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></tbody></table></div></blockquote>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto: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>
</div></div><br>_______________________________________________<br>
postgis-users mailing list<br>
<a rel="nofollow" ymailto="mailto:postgis-users@lists.osgeo.org" target="_blank" href="mailto: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>
</div><br>_______________________________________________<br>postgis-users mailing list<br><a ymailto="mailto:postgis-users@lists.osgeo.org" href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users</a><br><br><br> </div> </div> </blockquote></div> </div></body></html>