[postgis] Re: postgis and shpfile library

smstnic smstnic at yahoo.ca
Fri Dec 14 18:47:19 PST 2001


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 at y..., "Obe, Regina     DND\\MIS" <Regina.Obe.PFD at 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 at r...]
> Sent: Friday, December 14, 2001 12:34 PM
> To: postgis at 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 at y...
> > 
> > 
> > 
> > Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/
> 
> -- 
>       __
>      /
>      | Paul Ramsey
>      | Refractions Research
>      | Email: pramsey at r...
>      | Phone: (250) 885-0632
>      \_
> 
> 
> To unsubscribe from this group, send an email to:
> postgis-unsubscribe at 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:
postgis-unsubscribe at yahoogroups.com

 

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





More information about the postgis-users mailing list