Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1and2M-0007HJ-H2 for pgsql-sql@arkaria.postgresql.org; Wed, 06 Apr 2016 02:17:42 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1and2L-0001iU-Qq for pgsql-sql@arkaria.postgresql.org; Wed, 06 Apr 2016 02:17:41 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1and1I-0000Xr-1X for pgsql-sql@postgresql.org; Wed, 06 Apr 2016 02:16:36 +0000 Received: from mail-qg0-x229.google.com ([2607:f8b0:400d:c04::229]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1and1E-0000Iv-LA for pgsql-sql@postgresql.org; Wed, 06 Apr 2016 02:16:34 +0000 Received: by mail-qg0-x229.google.com with SMTP id f105so2154374qge.2 for ; Tue, 05 Apr 2016 19:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=uWKOJCsiI/aWnWyZOOXPxSl48mp4PZ5vPkra4J5xWek=; b=tlV5CEUU0v9hrM2HTylQNuieB/b49B5QabbpoUjVQ/kecZrnTYRuy2RciRMA7cKv0/ BU8eXaRhF7xQi/6aVkRgFsc8HMod4IOOv96MEZnNK/jwVkpPKcqsWnUfFDmy4mmuMbXc pEvROa8BToBgf0V9BBU7qs+jTVemVF2KwO1wLXF2TtqQ7E+dW43FN0yTKATxyxyitfII 3Jb9eRLp9rYqn9VoWU2E0reP83OQM6WFge1uPQfwapurB1+JQ5RzCe0Cqewxqgg4/VUC PEZG66Peu1osJT/ZMnGSwya65SmAAjGxYqXF2CulhtFJCo2uKcfSnqfZWP0pKXIElkMh Yylg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:to:references:cc:from:message-id :date:user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=uWKOJCsiI/aWnWyZOOXPxSl48mp4PZ5vPkra4J5xWek=; b=lqt5eKFa7lLW1GzBLPPuZRqdgyZZhHgYmJtKcI1VxEceUKZOfl0KkWMXWoUgUgM16g 2H5aLRjekf13HbSxaqNaUJNAptrR+r4TEv3j7n18C9S/xfA8DEtRUelNHCfp0rQUyDyd NlCVxva6ZUmfYGXw4nNlpkGQbzBnAcHo8VDjUA2E6cUly/prxUyC9DFQNXUnhbpT+Juq juvKm8vGlVduhcGX+jhsAB5mOzbvIQpbsJCz+9erJ/XUZUHu3Aw1HQu/TaG9QTzTDx8q W4Hm/v1U5F+XMB3NVTo3D4Ko4o4q2N6y7p7qIwj19PGzujDXjthiuxS1DGE1dLzSw3YH 0b2A== X-Gm-Message-State: AD7BkJKZ28D8kAVVznTrB/8LvsAGvuJtFxjfgJIIM2s+I/+NfWCl8k72GdwdBVlCGC4d0w== X-Received: by 10.140.155.7 with SMTP id b7mr24703187qhb.14.1459908991860; Tue, 05 Apr 2016 19:16:31 -0700 (PDT) Received: from [192.168.1.250] (pool-108-36-89-175.phlapa.fios.verizon.net. [108.36.89.175]) by smtp.gmail.com with ESMTPSA id y89sm345177qgd.5.2016.04.05.19.16.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Apr 2016 19:16:30 -0700 (PDT) Subject: Re: Geometry vs Geography (what to use) To: Michael Moore References: Cc: postgres list From: Lee Hachadoorian Message-ID: <57047181.3060106@gmail.com> Date: Tue, 5 Apr 2016 22:16:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org Mike,

My spatial_ref_sys does not have an entry for SRID 8307 either, and I wonder what query exactly you tried, because I'm not sure how that SRID would appear. I thought your original data were in 4326, and geography defaults to 4326 if an SRID is not specified (and I think prior to PostGIS 2.1, not SRID other 4326 was possible for geography type).

Since most (recent) versions of PostGIS will be populated spatial_ref_sys automatically during installation, the empty spatial_ref_sys is odd. What is result of SELECT version() and SELECT postgis_full_version()?

Your statements to ALTER TABLE, UPDATE, and CREATE INDEX all look correct. However, I would have your DBAs confirm that your PostGIS installation is set up correctly before anything else.

As an aside, you would probably get more responses from the PostGIS Users mailing list (postgis-users@lists.osgeo.org) or gis.stackexchange.com.

Best,
--Lee


On 04/05/2016 05:56 PM, Michael Moore wrote:


Lee,
I tried casting to geography, but I get this:
ERROR:  GetProj4StringSPI: Cannot find SRID (8307) in spatial_ref_sys
********** Error **********
So, I discovered that "select * from spatial_ref_sys;" gives no results, meaning that the table is empty. I'll be talking with our DBAs about this. 

That being as it may, I read on somebody's blog that casting to geography can really slow things down so my plan is to add a new column like this:
alter table tpostalcoordinate  add column geography_position geography(POINT,4326) ;
then I will populate it like this:
UPDATE tpostalcoordinate set  geography_position = ST_SetSRID(ST_Point( longitude,  latitude), 4326);
and build an index like:
 CREATE INDEX tpostal_geo_geography_idx ON tpostalcoordinate USING gist(geography_position);

I'll let every know how it goes.


-- 
Lee Hachadoorian
Assistant Professor of Instruction, Geography & Urban Studies
Assistant Director, Professional Science Master's in GIS
Temple University
http://geospatial.commons.gc.cuny.edu
http://freecity.commons.gc.cuny.edu