[postgis-users] Newbie questions: SRIDs, function return values

Paul Ramsey pramsey at cleverelephant.ca
Thu May 15 07:29:09 PDT 2008


There's no universal answer to this, but I have long thought that a
simple answer suitable for may people would be a ST_UTM(geom) wrapper
on transform that picks the appropriate UTM zone for a given geometry.
It would work perfectly well for any collection of small objects. It
would fall apart for larger things like states and countries that are
of similar size to a UTM zone.

P

(for items that cross a zone boundary, eenie, meenie, minie, moe)

On Thu, May 15, 2008 at 6:20 AM, Burgholzer,Robert
<rwburgholzer at deq.virginia.gov> wrote:
> Paul,
> Nice example on that generic spatial ref system for calculating
> distances and areas in the continental US.   This reminds me of a thread
> about this a week or two ago.  It seems to me that the need exists (or
> at lease it could be useful) for an area/distance functions that can
> make some intelligent guesses about the best coordinate system to
> reproject (transform) a given set of geometries into for the purposes of
> accurate measurements.  Something like:
>
> St_AreaUnits(geom_col, units)
> St_distanceUnits(geom._col, units)
>
> I am wondering if there is some logic out there that could be applied to
> create a function that would evaluate the extent of the area and compare
> it to the projection information described in the spatial_ref_sys table
> to determine what srid (with the desired units) would have the greatest
> chance of encompassing the area of interest and then do the transform
> and measurement for the user.
>
> Any recommendations as to the functions to look at within the existing
> postgis suite to find the gizmos that pull apart the spatial
> descriptions to determine this?
>
> Or is this line of reasoning based on flawed assumptions?
>
> Thanks!
>
> Robert W. Burgholzer
> Surface Water Modeler
> Office of Water Supply and Planning
> Virginia Department of Environmental Quality
> rwburgholzer at deq.virginia.gov
> 804-698-4405
> Open Source Modeling Tools:
> http://sourceforge.net/projects/npsource/
>
> -----Original Message-----
> From: postgis-users-bounces at postgis.refractions.net
> [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Paul
> Ramsey
> Sent: Wednesday, May 14, 2008 6:36 PM
> To: PostGIS Users Discussion
> Subject: Re: [postgis-users] Newbie questions: SRIDs, function return
> values
>
> The zillow data is in lat/lon, so use -s 4326.
> lat/lon is not a planar projection, so the units returned are pretty
> non-sensical: square degrees for area, linear degrees for distance.
>
> Once you have your data correctly flagged with respect to its source
> projection, you can transform it.
>
> Add a new entry for a continental USA projection:
>
> INSERT INTO SPATIAL_REF_SYS VALUES (1000000,'ME',1000000,'','+proj=aea
> +lat_0=23 +lon_0=-96 +lat_1=29.5 +lat_2=45.5 +datum=NAD83
> +ellps=GRS80');
>
> Then use it to calculate area:
>
> SELECT area(transform(the_geom),1000000) FROM neighborhoods WHERE name
> = 'Ballard';
>
>
> P
>
> On Wed, May 14, 2008 at 3:13 PM, David Jantzen <david at culturemob.com>
> wrote:
>> Hi All,
>>
>> I'm brand spanking new to the GIS world, so I've got some pretty dumb
>> questions.  If the answer is "RTFM" that's fine, please just be
> specific
>> about which documentation to look at.
>>
>> What I'm trying to do:
>> 1) Properly load the Zillow neighborhood shapefiles into a PostGIS
>> enabled database.
>> 2) Write some test queries to learn about the dataset and PostGIS
>> functionality.
>> 3) Take a lat/long and convert it to the appropriate neighborhood.
>>
>> I've made some progress on #1, but I'm not sure I've done it properly
>> with respect to the SRID.  I loaded the Washington state data with
> this
>> command:
>>
>> shp2pgsql ZillowNeighborhoods-WA.shp neighborhoods | psql GeoTest -U
>> postgres
>>
>> The data loads without error and geometry_columns now contains:
>>
>> f_table_name  | f_geometry_column |coord_dimension | srid |  type
>>
> -----------------+----------------+---------------+-------------------+-
> -
>> neighborhoods | the_geom          |              2 |   -1 |
> MULTIPOLYGON
>>
>> I'm concerned that I have to specify the correct SRID, however I don't
>> see it anywhere in the Zillow .prj files, so I'm letting it default to
>> -1 hoping it will be magically correct.  I suspect this may be
>> problematic.
>>
>> Next, I'm attempting some basic queries, such as:
>> select area(the_geom) from neighborhoods where name = 'Ballard';
>>         area
>> ----------------------
>>  0.000461824752619577
>>
>> select distance((select the_geom from neighborhoods where name =
>> 'Ballard'),(select the_geom from neighborhoods where name =
>> 'Georgetown'));
>>      distance
>> --------------------
>>  0.0982236357558739
>>
>> My question is, what do these return values *mean*? I read in the FAQ
>> that "ST_Distance always returns in the units of the projection."
> which
>> I assume applies to other functions as well.  And my understanding is
>> that the units of the projection is determined by the SRID, and if
>> that's wrong then any conclusions derived from it would be wrong as
>> well.  Right?  So I'm kind of stuck here.  Is the -1 SRID really a
>> problem?  How do I find the real SRID if it is?
>>
>> Thanks for your help,
>> David
>>
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list