[postgis-users] Difficulty importing example file nyc_buildings.sql

2011-08-15 Thread b...@brucecallander.com
I am following the Geoserver Getting Started documentation in order to create 
an example PostGIS table.

I am working on a MacBook running Snow Leopard v10.6.8

Thanks to previous advice from the forum (Nicolas Ribot) I was able to create 
the sample database 'nyc' based on the template 'template_postgis'.

I am now encountering errors in trying to move to the next stage of importing 
the file 'nyc_buildings.sql' into the database.

The Unix command I am using is:

$ /usr/local/pgsql-9.0/bin/psql -f /Users/bacmac/nyc_buildings.sql nyc 

The Geoserver instructions are not explicit about where to put the 
nyc_buildings.sql file so I have left it in my own user directory 'bacmac'.

Execution of the command produces a string of errors beginning with:

CREATE TABLE
psql:/Users/bacmac/nyc_buildings.sql:4: ERROR:  function 
addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does 
not exist
LINE 1: SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts.
psql:/Users/bacmac/nyc_buildings.sql:5: ERROR:  current transaction is aborted, 
commands ignored until end of transaction block
psql:/Users/bacmac/nyc_buildings.sql:6: ERROR:  current transaction is aborted 
... and so on.


I realise that part of my difficulties stem from a lack of conceptual awareness 
of how the various parts of PostGIS fit together (databases, data stores, 
tables, clusters...) and what directory structure the PostGIS installation 
creates. I am very familiar with Access databases but that may be dangerous 
because the basic paradigm for PostGIS may be different. Are there any diagrams 
out there that give a basic conceptual view of Geoserver and PostIGIS? Also, I 
am coming at this from an enterprise SDI policy and implementation end, not 
from an IT/Unix background (probably very obvious!). Trying to construct a 
coherent overall picture based on the predominantly text-based, IT-heavy advice 
online is proving a challenge.

Many thanks 

Bruce Callander
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] Proper usage of Schema's

2011-08-15 Thread aperi2007

Hi,

The esri world work always in an unique DB schema.
So a single dataset is a group of tables in the same schema of the 
other datasets.


I don't understand why you need to use distinct schemas to separate they.

However I think you could do it.

You must install postgis in the public schema but
of course you can create and insert gis data in other schemas
setting correctly the search_path and the grants.

So I guess you could create a schema
hydrography and a schema roads and a schema boundaries.
And (i guess) you could define some relational foreign key between
a table in the hydrography schema and a table in the boundaries schema.

AFAIK I don't know if this is a correct mimic for esri world, more again 
I don't know if esri allow to define a foreign constraint between two 
distinct datasets, but I guess this is a good use for the schemas in a 
postgres+postgis DB.



Regards,
Andrea.
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] Distances off in the Southern US

2011-08-15 Thread Mike Hostetler
Hello,

I'm somewhat new to GIS and I have a problem that I thought appeared to be
simply using a wrong projection or datum, but it seems to be a bit more
subtle than that.

I have a table of cities in the US and I'm trying to find distances between
them. When I use a city that is in the northern US, it works fine.  When I
try to find the distance between two cities in the Southern US, the distance
becomes way off.

I setup a Geometry in my cities table and populated it like the following:

select AddGeometryColumn('cities','geom',32661,'POINT',2);
UPDATE cities SET  geom=transform(setsrid(makepoint(longitude,
latitude),4269), 32661)

(I find the latitude and longitude from the Yahoo Geocode service)

A distance calc from McHenry, IL to Dallas, TX is calculated as:
select distance( (select geom from cities where id=26251), (select geom from
cities where id=67) )*0.000621371192 as miles;
 miles
--
 996.717850542391
(Google Maps reads as 972, off by 25 miles or off around 4%)


But Birmingham, AL, to Miami, FL is calculated as:
leader=# select distance( (select geom from cities where id=26251), (select
geom from cities where id=67) )*0.000621371192 as miles;
  miles
--
 996.717850542391
(Google Maps reads as 767, off by 120 files, or 13%).

I can handle a little error, as long as it's somewhat small (5%).  But this
is way off.

Again, it smells to be to be a datum or projection issue to me, but I'm not
sure how to find the sweet spot to be accurate everywhere.

Your input is appreciated.


-- 
Mike Hostetler
SquarePeg Systems
http://www.squarepegsystems.com
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Difficulty importing example file nyc_buildings.sql

2011-08-15 Thread Andrew Libby


Hi Bruce,

I'm pretty new to GIS and PostGIS, but I'll try to offer an
idea.  It appears that you might not have the postgis code
loaded.  I'm going to guess that Nicholas' suggestion
involved setting up the template_postgis database so that
you might make postgis enabled databases without manually
importing the postgis.sql and the spatial_ref_sys.sql?

Are you confident that you did this properly?  The error
you're getting makes me thing that the postgis stored
procedures are not properly loaded.

If you log into the DB using psql and execute

\df+ AddGeometryColumn

Do you get an emptry result?  If this is not the case you
might try the same on your template database.

Good luck,

Andy





On 8/15/11 6:28 AM, b...@brucecallander.com wrote:

I am following the Geoserver Getting Started documentation in order to create 
an example PostGIS table.

I am working on a MacBook running Snow Leopard v10.6.8

Thanks to previous advice from the forum (Nicolas Ribot) I was able to create 
the sample database 'nyc' based on the template 'template_postgis'.

I am now encountering errors in trying to move to the next stage of importing 
the file 'nyc_buildings.sql' into the database.

The Unix command I am using is:

$ /usr/local/pgsql-9.0/bin/psql -f /Users/bacmac/nyc_buildings.sql nyc

The Geoserver instructions are not explicit about where to put the 
nyc_buildings.sql file so I have left it in my own user directory 'bacmac'.

Execution of the command produces a string of errors beginning with:

CREATE TABLE
psql:/Users/bacmac/nyc_buildings.sql:4: ERROR:  function 
addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does 
not exist
LINE 1: SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts.
psql:/Users/bacmac/nyc_buildings.sql:5: ERROR:  current transaction is aborted, 
commands ignored until end of transaction block
psql:/Users/bacmac/nyc_buildings.sql:6: ERROR:  current transaction is aborted 
... and so on.


I realise that part of my difficulties stem from a lack of conceptual awareness 
of how the various parts of PostGIS fit together (databases, data stores, 
tables, clusters...) and what directory structure the PostGIS installation 
creates. I am very familiar with Access databases but that may be dangerous 
because the basic paradigm for PostGIS may be different. Are there any diagrams 
out there that give a basic conceptual view of Geoserver and PostIGIS? Also, I 
am coming at this from an enterprise SDI policy and implementation end, not 
from an IT/Unix background (probably very obvious!). Trying to construct a 
coherent overall picture based on the predominantly text-based, IT-heavy advice 
online is proving a challenge.

Many thanks

Bruce Callander
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


--


xforty technologies
Andrew Libby
http://xforty.com
484-887-7505 x 1115

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Distances off in the Southern US

2011-08-15 Thread Nicolas Ribot
On 15 August 2011 12:50, Mike Hostetler m...@squarepegsystems.com wrote:
 Hello,
 I'm somewhat new to GIS and I have a problem that I thought appeared to be
 simply using a wrong projection or datum, but it seems to be a bit more
 subtle than that.
 I have a table of cities in the US and I'm trying to find distances between
 them. When I use a city that is in the northern US, it works fine.  When I
 try to find the distance between two cities in the Southern US, the distance
 becomes way off.
 I setup a Geometry in my cities table and populated it like the following:
 select AddGeometryColumn('cities','geom',32661,'POINT',2);
 UPDATE cities SET  geom=transform(setsrid(makepoint(longitude,
 latitude),4269), 32661)
 (I find the latitude and longitude from the Yahoo Geocode service)
 A distance calc from McHenry, IL to Dallas, TX is calculated as:
 select distance( (select geom from cities where id=26251), (select geom from
 cities where id=67) )*0.000621371192 as miles;
      miles
 --
  996.717850542391
 (Google Maps reads as 972, off by 25 miles or off around 4%)

 But Birmingham, AL, to Miami, FL is calculated as:
 leader=# select distance( (select geom from cities where id=26251), (select
 geom from cities where id=67) )*0.000621371192 as miles;
       miles
 --
  996.717850542391
 (Google Maps reads as 767, off by 120 files, or 13%).
 I can handle a little error, as long as it's somewhat small (5%).  But this
 is way off.
 Again, it smells to be to be a datum or projection issue to me, but I'm not
 sure how to find the sweet spot to be accurate everywhere.
 Your input is appreciated.


Hi Mike,

Some remarks:
• Are you sure Yahoo! Geocoder Service returns degree expressed on
4269 coordinate system ? I read it is 4326.
• How did you get the distances with Google Maps ? Did you use travel
directions ? If so, the 972 miles is by driving on roads, not by
flying the shortest distance (great circle).

The following service:
http://www.geobytes.com/CityDistanceTool.htm?loadpage
gave me a direct distance of 808 miles or 1300km for McHenry - Dallas
and a distance of 658 miles or 1059 km for Birmingham - Miami.

Then, by running these queries the distance between cities seems to be good:

select foo.city, bar.city, st_distance(foo.geom,
bar.geom)*0.000621371192 as miles
from
(select 'McHenry' as city, 'IL' as state, 'POINT(-88.267314
42.326215)'::geography as geom) as foo,
(select 'Dallas' as city, 'TX' as state, 'POINT(-96.795404
32.778155)'::geography as geom) as bar;

city   |  city  |  miles
-++--
 McHenry | Dallas | 807.029700174124

select foo.city, bar.city, st_distance(foo.geom,
bar.geom)*0.000621371192 as miles
from
(select 'Birmingham' as city, 'AL' as state, 'POINT(-86.811504
33.520295)'::geography as geom) as foo,
(select 'Miami' as city, 'FL' as state, 'POINT(-80.237419
25.728985)'::geography as geom) as bar

city| city  |  miles
+---+--
 Birmingham | Miami | 666.318599210394

The slight differences between CityDistanceTool and Yahoo! services
come from the cities coordinates: the two services do not position
cities at the same coordinates.

Also please note I'm using the new GEOGRAPHY Postgis type that allows
direct distance computation: no need to transform data back to a
planar coordinate system.
If you use geometry type with long/lat coordinates, you may have a
look at st_distanceSphere and st_distanceSpheroid.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Distances off in the Southern US

2011-08-15 Thread Dan Putler

Hi Mike and Nicolas,

The fact that Mike's two calculations resulted in the same value to 12 
decimal places is more that a little fishy. I seem to remember a similar 
issue coming up on this list sometime ago (roughly a year ago is my, 
faulty, memory). The difference between southern and northern cities in 
the US just shouldn't be an issue if the data was read in correctly.


Dan

On 08/15/2011 06:18 AM, Nicolas Ribot wrote:

On 15 August 2011 12:50, Mike Hostetlerm...@squarepegsystems.com  wrote:

Hello,
I'm somewhat new to GIS and I have a problem that I thought appeared to be
simply using a wrong projection or datum, but it seems to be a bit more
subtle than that.
I have a table of cities in the US and I'm trying to find distances between
them. When I use a city that is in the northern US, it works fine.  When I
try to find the distance between two cities in the Southern US, the distance
becomes way off.
I setup a Geometry in my cities table and populated it like the following:
select AddGeometryColumn('cities','geom',32661,'POINT',2);
UPDATE cities SET  geom=transform(setsrid(makepoint(longitude,
latitude),4269), 32661)
(I find the latitude and longitude from the Yahoo Geocode service)
A distance calc from McHenry, IL to Dallas, TX is calculated as:
select distance( (select geom from cities where id=26251), (select geom from
cities where id=67) )*0.000621371192 as miles;
  miles
--
  996.717850542391
(Google Maps reads as 972, off by 25 miles or off around 4%)

But Birmingham, AL, to Miami, FL is calculated as:
leader=# select distance( (select geom from cities where id=26251), (select
geom from cities where id=67) )*0.000621371192 as miles;
   miles
--
  996.717850542391
(Google Maps reads as 767, off by 120 files, or 13%).
I can handle a little error, as long as it's somewhat small (5%).  But this
is way off.
Again, it smells to be to be a datum or projection issue to me, but I'm not
sure how to find the sweet spot to be accurate everywhere.
Your input is appreciated.


Hi Mike,

Some remarks:
• Are you sure Yahoo! Geocoder Service returns degree expressed on
4269 coordinate system ? I read it is 4326.
• How did you get the distances with Google Maps ? Did you use travel
directions ? If so, the 972 miles is by driving on roads, not by
flying the shortest distance (great circle).

The following service:
http://www.geobytes.com/CityDistanceTool.htm?loadpage
gave me a direct distance of 808 miles or 1300km for McHenry - Dallas
and a distance of 658 miles or 1059 km for Birmingham - Miami.

Then, by running these queries the distance between cities seems to be good:

select foo.city, bar.city, st_distance(foo.geom,
bar.geom)*0.000621371192 as miles
from
(select 'McHenry' as city, 'IL' as state, 'POINT(-88.267314
42.326215)'::geography as geom) as foo,
(select 'Dallas' as city, 'TX' as state, 'POINT(-96.795404
32.778155)'::geography as geom) as bar;

city   |  city  |  miles
-++--
  McHenry | Dallas | 807.029700174124

select foo.city, bar.city, st_distance(foo.geom,
bar.geom)*0.000621371192 as miles
from
(select 'Birmingham' as city, 'AL' as state, 'POINT(-86.811504
33.520295)'::geography as geom) as foo,
(select 'Miami' as city, 'FL' as state, 'POINT(-80.237419
25.728985)'::geography as geom) as bar

city| city  |  miles
+---+--
  Birmingham | Miami | 666.318599210394

The slight differences between CityDistanceTool and Yahoo! services
come from the cities coordinates: the two services do not position
cities at the same coordinates.

Also please note I'm using the new GEOGRAPHY Postgis type that allows
direct distance computation: no need to transform data back to a
planar coordinate system.
If you use geometry type with long/lat coordinates, you may have a
look at st_distanceSphere and st_distanceSpheroid.

Nicolas
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Vishal Mehta
Can anyone tell me if Postgis rasters can be displayed in OpenLayers?

We are trying to develop a web-gis stack (so far Postggresql - Postgis - PhP 
-OpenLayers) on an external server. I'm wondering if we can have raster 
functionality as well as display with postgis alone as the map server...without 
using Geoserver of Mapserver.

Thank you,
Vishal

Vishal K. Mehtahttp://sei-us.org/about/staff_person/19, Ph.D.
Staff Scientist,
Stockholm Environment Institute-US
400 F St, Davis, CA 95616
http://sei-us.org/



___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Pierre Racine
I don't think there is anything in OpenLayer able to speak directly with 
PostGIS... You need something in between able to deliver tiles. If your php 
code can do that... But why trying to reinvent a tile server other than 
MapServer or GeoServer?

Pierre

 -Original Message-
 From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-
 boun...@postgis.refractions.net] On Behalf Of Vishal Mehta
 Sent: Monday, August 15, 2011 1:43 PM
 To: postgis-users@postgis.refractions.net
 Cc: Eric Kemp-Benedict; Douglas Wang
 Subject: [postgis-users] Postgis rasters in OpenLayers?
 
 Can anyone tell me if Postgis rasters can be displayed in OpenLayers?
 
 
 
 We are trying to develop a web-gis stack (so far Postggresql - Postgis - PhP -
 OpenLayers) on an external server. I'm wondering if we can have raster
 functionality as well as display with postgis alone as the map 
 server...without
 using Geoserver of Mapserver.
 
 
 
 Thank you,
 
 Vishal
 
 
 
 Vishal K. Mehta http://sei-us.org/about/staff_person/19 , Ph.D.
 
 Staff Scientist,
 
 Stockholm Environment Institute-US
 
 400 F St, Davis, CA 95616
 
 http://sei-us.org/
 
 
 
 
 
 

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Dave Potts
On 15/08/11 18:53, Pierre Racine wrote:

Use geoserver which can make a request to a postgis database and supply
data as  wfs or wms servers.  You can then use openlayers to access the
wfs/wms server
 I don't think there is anything in OpenLayer able to speak directly with 
 PostGIS... You need something in between able to deliver tiles. If your php 
 code can do that... But why trying to reinvent a tile server other than 
 MapServer or GeoServer?

 Pierre

 -Original Message-
 From: postgis-users-boun...@postgis.refractions.net [mailto:postgis-users-
 boun...@postgis.refractions.net] On Behalf Of Vishal Mehta
 Sent: Monday, August 15, 2011 1:43 PM
 To: postgis-users@postgis.refractions.net
 Cc: Eric Kemp-Benedict; Douglas Wang
 Subject: [postgis-users] Postgis rasters in OpenLayers?

 Can anyone tell me if Postgis rasters can be displayed in OpenLayers?



 We are trying to develop a web-gis stack (so far Postggresql - Postgis - PhP 
 -
 OpenLayers) on an external server. I'm wondering if we can have raster
 functionality as well as display with postgis alone as the map 
 server...without
 using Geoserver of Mapserver.



 Thank you,

 Vishal



 Vishal K. Mehta http://sei-us.org/about/staff_person/19 , Ph.D.

 Staff Scientist,

 Stockholm Environment Institute-US

 400 F St, Davis, CA 95616

 http://sei-us.org/






 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Vishal Mehta
Thanks Dave, Pierre,

There were a couple of reasons for my qn: 

For an earlier application, we used postgis as a map repository and 
geoprocessor, php to interact dynamically with the map repository and perform 
gis operations, R to create graphs, and google earth as the visual frontend. 
http://108.195.205.37/kml/DataGrid.kmz

So I wanted to check if with OpenLayers instead of Google Earth as the client, 
I could do the same and just have a sparse geospatial stack. 

Another reason is that we'll need to find a hosting provider and are wondering 
if we can find one with all the capabilities or flexibility to put up 
experimental versions of software and have all these individual software hosted.

One other qn I had was : Can Geoserver 'speak' with Postgis 2.0 rasters?

Thanks again!
V

-Original Message-
From: postgis-users-boun...@postgis.refractions.net 
[mailto:postgis-users-boun...@postgis.refractions.net] On Behalf Of Dave Potts
Sent: Monday, August 15, 2011 10:59 AM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Postgis rasters in OpenLayers?

On 15/08/11 18:53, Pierre Racine wrote:

Use geoserver which can make a request to a postgis database and supply data as 
 wfs or wms servers.  You can then use openlayers to access the wfs/wms server
 I don't think there is anything in OpenLayer able to speak directly with 
 PostGIS... You need something in between able to deliver tiles. If your php 
 code can do that... But why trying to reinvent a tile server other than 
 MapServer or GeoServer?

 Pierre

 -Original Message-
 From: postgis-users-boun...@postgis.refractions.net 
 [mailto:postgis-users- boun...@postgis.refractions.net] On Behalf Of 
 Vishal Mehta
 Sent: Monday, August 15, 2011 1:43 PM
 To: postgis-users@postgis.refractions.net
 Cc: Eric Kemp-Benedict; Douglas Wang
 Subject: [postgis-users] Postgis rasters in OpenLayers?

 Can anyone tell me if Postgis rasters can be displayed in OpenLayers?



 We are trying to develop a web-gis stack (so far Postggresql - 
 Postgis - PhP -
 OpenLayers) on an external server. I'm wondering if we can have 
 raster functionality as well as display with postgis alone as the map 
 server...without using Geoserver of Mapserver.



 Thank you,

 Vishal



 Vishal K. Mehta http://sei-us.org/about/staff_person/19 , Ph.D.

 Staff Scientist,

 Stockholm Environment Institute-US

 400 F St, Davis, CA 95616

 http://sei-us.org/






 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Distances off in the Southern US

2011-08-15 Thread Mike Hostetler
I'll try to answer everyone's suggestions:

I didn't know that Yahoo's service was in 4326.  That did change things up a
bit.  And, yes, I did copy the value from Birmingham to Miami twice. Sorry
about that. . .

My customer was comparing my results to a different source but it seems
close to Google Maps.  I know that I was using the road miles in Birmingham
to Miami (
and other southern cites) but my other mileage to the northern cities was
5% off from the Google Maps was.  So that I was kinda close.

Now I combined a lot of the suggestions, so now my Geometry looks like:
select AddGeometryColumn('cities','geom',2163,'POINT',2);
UPDATE cities SET  geom=transform(setsrid(makepoint(longitude,
latitude),4326),2163

Birmingham to Miami is:
leader=# select distance( (select geom from cities where id=104), (select
geom from cities where id=41) )*0.000621371192 as miles;
  miles
--
 656.738138375537
(1 row)


Which is around 13% off in the other direction.

But  McHenry to Dallas is now off from what I had:
leader=# select distance( (select geom from cities where id=26251), (select
geom from cities where id=67) )*0.000621371192 as miles;
 miles
---
 808.949257448
(1 row)

it was 997, which was close to Google Maps. Now it's further off.

But I understand what everyone is saying, and makes sense that flying
distance would be shorter than the road distance.  I think I'm comparing
apples to oranges and it was by chance that some random samples I tested
with were close.  I think I need to find some interstate shapefiles, put
them in, and have PostGIS calculate the distance between those points on
that route.

Thanks everyone.

On Mon, Aug 15, 2011 at 11:04 AM, Paul Ramsey pram...@opengeo.org wrote:

 You're using polar stereograpic as your projection?

 http://nsidc.org/data/atlas/epsg_32661.html

 Well, yes, the farther south you go, the more over-determined your
 distance will be.

 Use the geography type, as suggested below, or the
 st_distance_spheroid() function, or just use a projection that is more
 conformal for the area of interest (continental USA?
 http://prj2epsg.org/epsg/2163)

 P.

 On Mon, Aug 15, 2011 at 3:50 AM, Mike Hostetler
 m...@squarepegsystems.com wrote:
  Hello,
  I'm somewhat new to GIS and I have a problem that I thought appeared to
 be
  simply using a wrong projection or datum, but it seems to be a bit more
  subtle than that.
  I have a table of cities in the US and I'm trying to find distances
 between
  them. When I use a city that is in the northern US, it works fine.  When
 I
  try to find the distance between two cities in the Southern US, the
 distance
  becomes way off.
  I setup a Geometry in my cities table and populated it like the
 following:
  select AddGeometryColumn('cities','geom',32661,'POINT',2);
  UPDATE cities SET  geom=transform(setsrid(makepoint(longitude,
  latitude),4269), 32661)
  (I find the latitude and longitude from the Yahoo Geocode service)
  A distance calc from McHenry, IL to Dallas, TX is calculated as:
  select distance( (select geom from cities where id=26251), (select geom
 from
  cities where id=67) )*0.000621371192 as miles;
   miles
  --
   996.717850542391
  (Google Maps reads as 972, off by 25 miles or off around 4%)
 
  But Birmingham, AL, to Miami, FL is calculated as:
  leader=# select distance( (select geom from cities where id=26251),
 (select
  geom from cities where id=67) )*0.000621371192 as miles;
miles
  --
   996.717850542391
  (Google Maps reads as 767, off by 120 files, or 13%).
  I can handle a little error, as long as it's somewhat small (5%).  But
 this
  is way off.
  Again, it smells to be to be a datum or projection issue to me, but I'm
 not
  sure how to find the sweet spot to be accurate everywhere.
  Your input is appreciated.
 
  --
  Mike Hostetler
  SquarePeg Systems
  http://www.squarepegsystems.com
 
  ___
  postgis-users mailing list
  postgis-users@postgis.refractions.net
  http://postgis.refractions.net/mailman/listinfo/postgis-users
 
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users




-- 
Mike Hostetler
SquarePeg Systems
http://www.squarepegsystems.com
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Pierre Racine
 So I wanted to check if with OpenLayers instead of Google Earth as the 
 client, I
 could do the same and just have a sparse geospatial stack.

The answer is in your php server. You decide... Everything depends on what is 
supported by the client. You had to develop a server for Google Earth. There 
are plenty of server for OpenLayer. If you develop your own then there should 
be no problem. What you need is to serve JPEG and PostGIS raster ST_AsJPEG() 
will help you to do that. 

 One other qn I had was : Can Geoserver 'speak' with Postgis 2.0 rasters?

See this recent discussion:

http://osgeo-org.1803224.n2.nabble.com/Geoserver-WCS-amp-PostGIS2-0-Raster-support-td6602643.html

Pierre
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Postgis rasters in OpenLayers?

2011-08-15 Thread Vishal Mehta
Thank you again Pierre,
Vishal

-Original Message-
From: postgis-users-boun...@postgis.refractions.net 
[mailto:postgis-users-boun...@postgis.refractions.net] On Behalf Of Pierre 
Racine
Sent: Monday, August 15, 2011 11:54 AM
To: PostGIS Users Discussion; dave.po...@pinan.co.uk
Cc: Eric Kemp-Benedict; Douglas Wang
Subject: Re: [postgis-users] Postgis rasters in OpenLayers?

 So I wanted to check if with OpenLayers instead of Google Earth as the 
 client, I could do the same and just have a sparse geospatial stack.

The answer is in your php server. You decide... Everything depends on what is 
supported by the client. You had to develop a server for Google Earth. There 
are plenty of server for OpenLayer. If you develop your own then there should 
be no problem. What you need is to serve JPEG and PostGIS raster ST_AsJPEG() 
will help you to do that. 

 One other qn I had was : Can Geoserver 'speak' with Postgis 2.0 rasters?

See this recent discussion:

http://osgeo-org.1803224.n2.nabble.com/Geoserver-WCS-amp-PostGIS2-0-Raster-support-td6602643.html

Pierre
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


[postgis-users] Importing a shape file with NAD83 / Conus Albers

2011-08-15 Thread Javier de la Torre
Hi all,

I got a shapefile with a .prj file on it. I pasted the contents to 
http://prj2epsg.org and got that this http://prj2epsg.org/epsg/5070

This srs does not seem to be in PostGIS so I am trying to add it. Now, the 
first thing I tried was sending it to spatialreference and I got this 
http://spatialreference.org/ref/sr-org/7178/

But it does not seem to include the proj4text data needed for postgis to do 
transformations.

I then tried loading it in OGR with Python doing this:

 srs = osr.SpatialReference()
 wkt = 'PROJCS[NAD83 / Conus Albers,   GEOGCS[NAD83, DATUM[North 
 American Datum 1983,   SPHEROID[GRS 1980, 6378137.0, 298.257222101, 
 AUTHORITY[EPSG,7019]],   TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0, 
 0.0],   AUTHORITY[EPSG,6269]], PRIMEM[Greenwich, 0.0, 
 AUTHORITY[EPSG,8901]], UNIT[degree, 0.017453292519943295], 
 AXIS[Geodetic longitude, EAST], AXIS[Geodetic latitude, NORTH], 
 AUTHORITY[EPSG,4269]],   PROJECTION[Albers Equal Area, 
 AUTHORITY[EPSG,9822]],   PARAMETER[central_meridian, -96.0],   
 PARAMETER[latitude_of_origin, 23.0],   PARAMETER[standard_parallel_1, 
 29.5],   PARAMETER[false_easting, 0.0],   PARAMETER[false_northing, 
 0.0],   PARAMETER[standard_parallel_2, 45.5],   UNIT[m, 1.0],   
 AXIS[Easting, EAST],   AXIS[Northing, NORTH],   
 AUTHORITY[EPSG,5070]]'
 srs.ImportFromWkt([wkt])
srs.ExportToProj4()

But I get ERROR 6: No translation for Albers Equal Area to PROJ.4 format is 
known.

Anybody knows how can I get the PROJ4TEXT from this?

Ideally what I would like is to inspect automatially a shapefile coming with a 
.prj file, try to find if it is in PostGIS and if not register the proj and 
import the data using shp2psql.


Thanks for any advice,

Javier.

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Importing a shape file with NAD83 / Conus Albers

2011-08-15 Thread Paul Ramsey
Try running MorphFromESRI on the srs before generating the proj4?
P

On Mon, Aug 15, 2011 at 2:25 PM, Javier de la Torre
jato...@vizzuality.com wrote:
 Hi all,
 I got a shapefile with a .prj file on it. I pasted the contents
 to http://prj2epsg.org and got that this http://prj2epsg.org/epsg/5070
 This srs does not seem to be in PostGIS so I am trying to add it. Now, the
 first thing I tried was sending it to spatialreference and I got
 this http://spatialreference.org/ref/sr-org/7178/
 But it does not seem to include the proj4text data needed for postgis to do
 transformations.
 I then tried loading it in OGR with Python doing this:
 srs = osr.SpatialReference()
 wkt = 'PROJCS[NAD83 / Conus Albers,   GEOGCS[NAD83,     DATUM[North
 American Datum 1983,       SPHEROID[GRS 1980, 6378137.0, 298.257222101,
 AUTHORITY[EPSG,7019]],       TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0,
 0.0],       AUTHORITY[EPSG,6269]],     PRIMEM[Greenwich, 0.0,
 AUTHORITY[EPSG,8901]],     UNIT[degree, 0.017453292519943295],
 AXIS[Geodetic longitude, EAST],     AXIS[Geodetic latitude, NORTH],
 AUTHORITY[EPSG,4269]],   PROJECTION[Albers Equal Area,
 AUTHORITY[EPSG,9822]],   PARAMETER[central_meridian, -96.0],
 PARAMETER[latitude_of_origin, 23.0],   PARAMETER[standard_parallel_1,
 29.5],   PARAMETER[false_easting, 0.0],   PARAMETER[false_northing,
 0.0],   PARAMETER[standard_parallel_2, 45.5],   UNIT[m, 1.0],
 AXIS[Easting, EAST],   AXIS[Northing, NORTH],
 AUTHORITY[EPSG,5070]]'
 srs.ImportFromWkt([wkt])
srs.ExportToProj4()
 But I get ERROR 6: No translation for Albers Equal Area to PROJ.4 format is
 known.
 Anybody knows how can I get the PROJ4TEXT from this?
 Ideally what I would like is to inspect automatially a shapefile coming with
 a .prj file, try to find if it is in PostGIS and if not register the proj
 and import the data using shp2psql.

 Thanks for any advice,
 Javier.

 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Importing a shape file with NAD83 / Conus Albers

2011-08-15 Thread Javier de la Torre
You mean:

srs.MorphFromESRI()
srs.ExportToProj4()

That still produce

srs.ExportToProj4()
ERROR 6: No translation for Albers Equal Area to PROJ.4 format is known.



On Aug 15, 2011, at 5:28 PM, Paul Ramsey wrote:

 Try running MorphFromESRI on the srs before generating the proj4?
 P
 
 On Mon, Aug 15, 2011 at 2:25 PM, Javier de la Torre
 jato...@vizzuality.com wrote:
 Hi all,
 I got a shapefile with a .prj file on it. I pasted the contents
 to http://prj2epsg.org and got that this http://prj2epsg.org/epsg/5070
 This srs does not seem to be in PostGIS so I am trying to add it. Now, the
 first thing I tried was sending it to spatialreference and I got
 this http://spatialreference.org/ref/sr-org/7178/
 But it does not seem to include the proj4text data needed for postgis to do
 transformations.
 I then tried loading it in OGR with Python doing this:
 srs = osr.SpatialReference()
 wkt = 'PROJCS[NAD83 / Conus Albers,   GEOGCS[NAD83, DATUM[North
 American Datum 1983,   SPHEROID[GRS 1980, 6378137.0, 298.257222101,
 AUTHORITY[EPSG,7019]],   TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0,
 0.0],   AUTHORITY[EPSG,6269]], PRIMEM[Greenwich, 0.0,
 AUTHORITY[EPSG,8901]], UNIT[degree, 0.017453292519943295],
 AXIS[Geodetic longitude, EAST], AXIS[Geodetic latitude, NORTH],
 AUTHORITY[EPSG,4269]],   PROJECTION[Albers Equal Area,
 AUTHORITY[EPSG,9822]],   PARAMETER[central_meridian, -96.0],
 PARAMETER[latitude_of_origin, 23.0],   PARAMETER[standard_parallel_1,
 29.5],   PARAMETER[false_easting, 0.0],   PARAMETER[false_northing,
 0.0],   PARAMETER[standard_parallel_2, 45.5],   UNIT[m, 1.0],
 AXIS[Easting, EAST],   AXIS[Northing, NORTH],
 AUTHORITY[EPSG,5070]]'
 srs.ImportFromWkt([wkt])
 srs.ExportToProj4()
 But I get ERROR 6: No translation for Albers Equal Area to PROJ.4 format is
 known.
 Anybody knows how can I get the PROJ4TEXT from this?
 Ideally what I would like is to inspect automatially a shapefile coming with
 a .prj file, try to find if it is in PostGIS and if not register the proj
 and import the data using shp2psql.
 
 Thanks for any advice,
 Javier.
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users
 
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Importing a shape file with NAD83 / Conus Albers

2011-08-15 Thread Paul Ramsey
Very odd. Well, the proj4text you want is:

+proj=aea +lon_0=-96 +lat_0=23 +lat_1=29.5 +lat_2=45.5 +datum=NAD83

But, why OGR cannot produce that? Don't know.

P

On Mon, Aug 15, 2011 at 2:38 PM, Javier de la Torre
jato...@vizzuality.com wrote:
 You mean:

 srs.MorphFromESRI()
 srs.ExportToProj4()

 That still produce

 srs.ExportToProj4()
 ERROR 6: No translation for Albers Equal Area to PROJ.4 format is known.



 On Aug 15, 2011, at 5:28 PM, Paul Ramsey wrote:

 Try running MorphFromESRI on the srs before generating the proj4?
 P

 On Mon, Aug 15, 2011 at 2:25 PM, Javier de la Torre
 jato...@vizzuality.com wrote:
 Hi all,
 I got a shapefile with a .prj file on it. I pasted the contents
 to http://prj2epsg.org and got that this http://prj2epsg.org/epsg/5070
 This srs does not seem to be in PostGIS so I am trying to add it. Now, the
 first thing I tried was sending it to spatialreference and I got
 this http://spatialreference.org/ref/sr-org/7178/
 But it does not seem to include the proj4text data needed for postgis to do
 transformations.
 I then tried loading it in OGR with Python doing this:
 srs = osr.SpatialReference()
 wkt = 'PROJCS[NAD83 / Conus Albers,   GEOGCS[NAD83,     DATUM[North
 American Datum 1983,       SPHEROID[GRS 1980, 6378137.0, 
 298.257222101,
 AUTHORITY[EPSG,7019]],       TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0,
 0.0],       AUTHORITY[EPSG,6269]],     PRIMEM[Greenwich, 0.0,
 AUTHORITY[EPSG,8901]],     UNIT[degree, 0.017453292519943295],
 AXIS[Geodetic longitude, EAST],     AXIS[Geodetic latitude, NORTH],
 AUTHORITY[EPSG,4269]],   PROJECTION[Albers Equal Area,
 AUTHORITY[EPSG,9822]],   PARAMETER[central_meridian, -96.0],
 PARAMETER[latitude_of_origin, 23.0],   PARAMETER[standard_parallel_1,
 29.5],   PARAMETER[false_easting, 0.0],   PARAMETER[false_northing,
 0.0],   PARAMETER[standard_parallel_2, 45.5],   UNIT[m, 1.0],
 AXIS[Easting, EAST],   AXIS[Northing, NORTH],
 AUTHORITY[EPSG,5070]]'
 srs.ImportFromWkt([wkt])
 srs.ExportToProj4()
 But I get ERROR 6: No translation for Albers Equal Area to PROJ.4 format is
 known.
 Anybody knows how can I get the PROJ4TEXT from this?
 Ideally what I would like is to inspect automatially a shapefile coming with
 a .prj file, try to find if it is in PostGIS and if not register the proj
 and import the data using shp2psql.

 Thanks for any advice,
 Javier.

 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users


 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Importing a shape file with NAD83 / Conus Albers

2011-08-15 Thread Javier de la Torre
Thanks Paul,

Now, it is a pity there is no way to automate this to a decent level.

Is there nobody working on a generic shapefile importer that can accept any 
sort of shapefile and try to load it using the .prj file?

I will keep trying :)

Javier.

On Aug 15, 2011, at 5:55 PM, Paul Ramsey wrote:

 Very odd. Well, the proj4text you want is:
 
 +proj=aea +lon_0=-96 +lat_0=23 +lat_1=29.5 +lat_2=45.5 +datum=NAD83
 
 But, why OGR cannot produce that? Don't know.
 
 P
 
 On Mon, Aug 15, 2011 at 2:38 PM, Javier de la Torre
 jato...@vizzuality.com wrote:
 You mean:
 
 srs.MorphFromESRI()
 srs.ExportToProj4()
 
 That still produce
 
 srs.ExportToProj4()
 ERROR 6: No translation for Albers Equal Area to PROJ.4 format is known.
 
 
 
 On Aug 15, 2011, at 5:28 PM, Paul Ramsey wrote:
 
 Try running MorphFromESRI on the srs before generating the proj4?
 P
 
 On Mon, Aug 15, 2011 at 2:25 PM, Javier de la Torre
 jato...@vizzuality.com wrote:
 Hi all,
 I got a shapefile with a .prj file on it. I pasted the contents
 to http://prj2epsg.org and got that this http://prj2epsg.org/epsg/5070
 This srs does not seem to be in PostGIS so I am trying to add it. Now, the
 first thing I tried was sending it to spatialreference and I got
 this http://spatialreference.org/ref/sr-org/7178/
 But it does not seem to include the proj4text data needed for postgis to do
 transformations.
 I then tried loading it in OGR with Python doing this:
 srs = osr.SpatialReference()
 wkt = 'PROJCS[NAD83 / Conus Albers,   GEOGCS[NAD83, DATUM[North
 American Datum 1983,   SPHEROID[GRS 1980, 6378137.0, 
 298.257222101,
 AUTHORITY[EPSG,7019]],   TOWGS84[1.0, 1.0, -1.0, 0.0, 0.0, 0.0,
 0.0],   AUTHORITY[EPSG,6269]], PRIMEM[Greenwich, 0.0,
 AUTHORITY[EPSG,8901]], UNIT[degree, 0.017453292519943295],
 AXIS[Geodetic longitude, EAST], AXIS[Geodetic latitude, NORTH],
 AUTHORITY[EPSG,4269]],   PROJECTION[Albers Equal Area,
 AUTHORITY[EPSG,9822]],   PARAMETER[central_meridian, -96.0],
 PARAMETER[latitude_of_origin, 23.0],   
 PARAMETER[standard_parallel_1,
 29.5],   PARAMETER[false_easting, 0.0],   PARAMETER[false_northing,
 0.0],   PARAMETER[standard_parallel_2, 45.5],   UNIT[m, 1.0],
 AXIS[Easting, EAST],   AXIS[Northing, NORTH],
 AUTHORITY[EPSG,5070]]'
 srs.ImportFromWkt([wkt])
 srs.ExportToProj4()
 But I get ERROR 6: No translation for Albers Equal Area to PROJ.4 format 
 is
 known.
 Anybody knows how can I get the PROJ4TEXT from this?
 Ideally what I would like is to inspect automatially a shapefile coming 
 with
 a .prj file, try to find if it is in PostGIS and if not register the proj
 and import the data using shp2psql.
 
 Thanks for any advice,
 Javier.
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users
 
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users
 
 ___
 postgis-users mailing list
 postgis-users@postgis.refractions.net
 http://postgis.refractions.net/mailman/listinfo/postgis-users

___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Difficulty importing example file nyc_buildings.sql

2011-08-15 Thread Ben Madin
Bruce,

On 15/08/2011, at 6:28 PM, b...@brucecallander.com wrote:

 $ /usr/local/pgsql-9.0/bin/psql -f /Users/bacmac/nyc_buildings.sql nyc 
 
 The Geoserver instructions are not explicit about where to put the 
 nyc_buildings.sql file so I have left it in my own user directory 'bacmac'.

It doesn't matter, as long as the -f part of the command describes it as you 
have. You may find it convenient to keep all these scripts together in a single 
directory somewhere while you are starting.

 Execution of the command produces a string of errors beginning with:
 
 CREATE TABLE
 psql:/Users/bacmac/nyc_buildings.sql:4: ERROR:  function 
 addgeometrycolumn(unknown, unknown, unknown, unknown, unknown, integer) does 
 not exist
 LINE 1: SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...
 HINT:  No function matches the given name and argument types. You might need 
 to add explicit type casts.
 psql:/Users/bacmac/nyc_buildings.sql:5: ERROR:  current transaction is 
 aborted, commands ignored until end of transaction block
 psql:/Users/bacmac/nyc_buildings.sql:6: ERROR:  current transaction is 
 aborted ... and so on.
 
 
 I realise that part of my difficulties stem from a lack of conceptual 
 awareness of how the various parts of PostGIS fit together (databases, data 
 stores, tables, clusters...) and what directory structure the PostGIS 
 installation creates. I am very familiar with Access databases but that may 
 be dangerous because the basic paradigm for PostGIS may be different. Are 
 there any diagrams out there that give a basic conceptual view of Geoserver 
 and PostIGIS? Also, I am coming at this from an enterprise SDI policy and 
 implementation end, not from an IT/Unix background (probably very obvious!). 
 Trying to construct a coherent overall picture based on the predominantly 
 text-based, IT-heavy advice online is proving a challenge.

One of the neat / good / bad / helpful / troublesome things that you can do in 
postgres is define two functions with the same name, as long as they have 
different parameters and or parameter types. In this case, the import script is 
loading your sql, but has inappropriately enclosed the srid in quotes '2908'

the function you want is:

text AddGeometryColumn(varchar schema_name, varchar table_name, varchar 
column_name, integer srid, varchar type, integer dimension);

which specify that the srid should be integer. Because your call starts like :

 SELECT AddGeometryColumn('','nyc_buildings','the_geom','2908...


it won't match one of the above calls (unknown can go into varchar columns, but 
not into integer columns, which must be integer.)

The quickest fix might be to edit the nyc.sql file and remove the quotes from 
around the srid part of the addgeometrycolumn call.

cheers

Ben


___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users