[postgis] postgis and shpfile library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[postgis] postgis and shpfile library

gispmpf

I`m using mapserver and postgis and i have a question witch i need
help:

Can I export PostGIS data to the shpfile format?
Using mapserver i have 3 layers using postGIS queries and i need to
export them to one shp?

Thanks
João.




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Break free. Great
American Smokeout
http://us.click.yahoo.com/3vN8tD/.pSDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



Reply | Threaded
Open this post in threaded view
|

Re: [postgis] postgis and shpfile library

Jeff Lounsbury
Use the pgsql2shp program that comes in your postgis install.
-Jeff

gispmpf wrote:

> I`m using mapserver and postgis and i have a question witch i need
> help:
>
> Can I export PostGIS data to the shpfile format?
> Using mapserver i have 3 layers using postGIS queries and i need to
> export them to one shp?
>
> Thanks
> João.
>
>
> To unsubscribe from this group, send an email to:
> [hidden email]
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/


To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



Reply | Threaded
Open this post in threaded view
|

Re: [postgis] postgis and shpfile library

David Blasby-3
Jeff lounsbury wrote:
>
> Use the pgsql2shp program that comes in your postgis install.
> -Jeff


If you're just trying to get the results of a query, you can create a
table with the query results and then dump the table.

CREATE TABLE blah AS (SELECT ....);

Perhaps jeff (or someone else) could extend the pgsql2shp program to
accept an sql query instead of a table name.

dave

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Quit now for Great
American Smokeout
http://us.click.yahoo.com/0vN8tD/9pSDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



Reply | Threaded
Open this post in threaded view
|

Re: [postgis] postgis and shpfile library

Paul Ramsey-2
Mapserver can also be used to write shape files as a result of a query,
with the mapscript extension, but it is notoriously finnicky to get that
functionality to work write, so I would not recommend it unless you are
very patient.

Dave Blasby wrote:

>
> Jeff lounsbury wrote:
> >
> > Use the pgsql2shp program that comes in your postgis install.
> > -Jeff
>
> If you're just trying to get the results of a query, you can create a
> table with the query results and then dump the table.
>
> CREATE TABLE blah AS (SELECT ....);
>
> Perhaps jeff (or someone else) could extend the pgsql2shp program to
> accept an sql query instead of a table name.
>
> dave
>
>
> To unsubscribe from this group, send an email to:
> [hidden email]
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

--
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: [hidden email]
     | Phone: (250) 885-0632
     \_

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Stop Smoking Now
Nicotrol will help
http://us.click.yahoo.com/2vN8tD/_pSDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



Reply | Threaded
Open this post in threaded view
|

RE: [postgis] postgis and shpfile library

Obe, Regina     DND\MIS
In reply to this post by gispmpf
I've been able to use pgsql2shp against Views too (treating views as if they
were tables) and seems to work pretty well.  The upside of using a view
would be that if you have a query you always run you don't have to dump the
query results every time into a static table - it will change as your base
tables change if you save the query as a view.  Also it's a quick way to
store the query and you can always DROP  it with DROP VIEW.

For Example instead of creating a table do something of the form

CREATE VIEW myview As
SELECT .... FROM ...


Then use the myview as if it were a table in the pgsql2shp call.

I was even able to create a view based on a UNION something of the form

CREATE VIEW myview AS
        SELECT t.Address, centroid(p.the_geom) as the_geom
                FROM table1 t INNER JOIN parcels p ON t.parcelid =
p.parcelid
        UNION
        SELECT t2.Address, centroid(the_geom) As the_geom
                FROM table2 t2 INNER JOIN parcels p ON t2.parcelid =
p.parcelid


Then used pgsql2shp to dump out the output with

pgsql2shp -h myserver mydb myview







-----Original Message-----
From: Paul Ramsey [mailto:[hidden email]]
Sent: Friday, December 14, 2001 12:34 PM
To: [hidden email]
Subject: Re: [postgis] postgis and shpfile library


Mapserver can also be used to write shape files as a result of a query,
with the mapscript extension, but it is notoriously finnicky to get that
functionality to work write, so I would not recommend it unless you are
very patient.

Dave Blasby wrote:

>
> Jeff lounsbury wrote:
> >
> > Use the pgsql2shp program that comes in your postgis install.
> > -Jeff
>
> If you're just trying to get the results of a query, you can create a
> table with the query results and then dump the table.
>
> CREATE TABLE blah AS (SELECT ....);
>
> Perhaps jeff (or someone else) could extend the pgsql2shp program to
> accept an sql query instead of a table name.
>
> dave
>
>
> To unsubscribe from this group, send an email to:
> [hidden email]
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/

--
      __
     /
     | Paul Ramsey
     | Refractions Research
     | Email: [hidden email]
     | Phone: (250) 885-0632
     \_


To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Win a Capcom Console Game.
http://us.click.yahoo.com/smpz8B/fxbDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 



Reply | Threaded
Open this post in threaded view
|

[postgis] Re: postgis and shpfile library

smstnic
I begin to work today on this function to, but not in pgsql2shp
project.  I think that something like -s option for sql query in
pgsql2shp is a good idea.  But to save time, I build a SQL function
with a xy min/max BOX input. This function create a view to make my
tempory spatial filter.

create view as select ... where geom && GeometryFromText('BOX3D...

Finnaly, I build a little c funtion in Postgresql that call pgsql2shp
with my tempory spatial view. The return is a simple shapefile path
for in a "www-data" or ftp directory for download.

select db2shp(mySpatialView, myDb,myshape)
------
/tmp/data/myshape.*

It's simple and easy to build for the web... maybe this could help
you...

Simon Mercier
www.financiereagricole.qc.ca






--- In postgis@y..., "Obe, Regina     DND\\MIS" <Regina.Obe.PFD@c...>
wrote:
> I've been able to use pgsql2shp against Views too (treating views
as if they
> were tables) and seems to work pretty well.  The upside of using a
view
> would be that if you have a query you always run you don't have to
dump the
> query results every time into a static table - it will change as
your base
> tables change if you save the query as a view.  Also it's a quick
way to

> store the query and you can always DROP  it with DROP VIEW.
>
> For Example instead of creating a table do something of the form
>
> CREATE VIEW myview As
> SELECT .... FROM ...
>
>
> Then use the myview as if it were a table in the pgsql2shp call.
>
> I was even able to create a view based on a UNION something of the
form

>
> CREATE VIEW myview AS
> SELECT t.Address, centroid(p.the_geom) as the_geom
> FROM table1 t INNER JOIN parcels p ON t.parcelid =
> p.parcelid
> UNION
> SELECT t2.Address, centroid(the_geom) As the_geom
> FROM table2 t2 INNER JOIN parcels p ON t2.parcelid =
> p.parcelid
>
>
> Then used pgsql2shp to dump out the output with
>
> pgsql2shp -h myserver mydb myview
>
>
>
>
>
>
>
> -----Original Message-----
> From: Paul Ramsey [mailto:pramsey@r...]
> Sent: Friday, December 14, 2001 12:34 PM
> To: postgis@y...
> Subject: Re: [postgis] postgis and shpfile library
>
>
> Mapserver can also be used to write shape files as a result of a
query,
> with the mapscript extension, but it is notoriously finnicky to get
that
> functionality to work write, so I would not recommend it unless you
are

> very patient.
>
> Dave Blasby wrote:
> >
> > Jeff lounsbury wrote:
> > >
> > > Use the pgsql2shp program that comes in your postgis install.
> > > -Jeff
> >
> > If you're just trying to get the results of a query, you can
create a
> > table with the query results and then dump the table.
> >
> > CREATE TABLE blah AS (SELECT ....);
> >
> > Perhaps jeff (or someone else) could extend the pgsql2shp program
to

> > accept an sql query instead of a table name.
> >
> > dave
> >
> >
> > To unsubscribe from this group, send an email to:
> > postgis-unsubscribe@y...
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/

>
> --
>       __
>      /
>      | Paul Ramsey
>      | Refractions Research
>      | Email: pramsey@r...
>      | Phone: (250) 885-0632
>      \_
>
>
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe@y...
>
>  
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Unlimited PC-PC calling at Crystal Voice! - Only $1/Mo.
Download your free 30 day trial. Click here.
http://us.click.yahoo.com/Gb1xVB/GxbDAA/ySSFAA/PhFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
[hidden email]

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/