[postgis-users] PostGIS Geography and Rhumb Lines

Derek Meyer derek at meyerprofessional.com
Wed Nov 28 23:23:29 PST 2012


Thank you strk, good suggestion.

I suppose my only remaining question really is the most basic.
Syntactically, how would the VALUE entry for such combination of
elements look?  How would one append that cast geography rhumb line
onto the end of a GEOMETRYCOLLECTION in a single query?  Would the
correct method be to use ST_Union to bring it all together, a la...

...INSERT INTO database_name VALUES ('$id',
ST_Union(ST_GeographyFromText('GEOMETRYCOLLECTION(LINESTRING(-28 -25,
-27.6 -25.5))'), ST_Segmentize(ST_GeomFromText('LINESTRING(-29 -27,-30
-29.7,-36 -31,-45 -33)', 3857), 5)::geography)...

?

Best regards,

- Derek

On Wed, Nov 28, 2012 at 12:12 PM, Sandro Santilli <strk at keybit.net> wrote:
> I would just cast the result to a geography:
>
>   ST_Segmentize(...)::geography
>
> --strk;
>
> On Wed, Nov 28, 2012 at 11:44:23AM -0800, Derek Meyer wrote:
>> Outstanding, thanks guys!
>>
>> So am I correct that with something like the below I'd have a
>> resulting geometry of coords out of a 2D plain, correct?  Assuming I
>> got an acceptable SRID for Mercator there (3857?).
>>
>> ST_Segmentize(ST_GeomFromText('LINESTRING(-29 -27,-30 -29.7,-36
>> -31,-45 -33)'), 3857), 5)
>>
>> Then when worked into a query that bundles everything up via
>> ST_GeographyFromText, that each tiny segment would be technically
>> great-circle again, but *overall* a reasonable rhumb line
>> representation cast by the previous segmentize?
>>
>> Makes sense to me.  My only other question would be probably a newbie
>> syntactical question regarding how to get the above segmentize result
>> within the SQL query.  Would I be using ST_AsText to return it to WKT
>> and concating it somehow within my ST_GeographyFromText line?  I'm
>> sure the below would probably break but, to see what I'm getting at...
>>
>> ST_GeographyFromText('GEOMETRYCOLLECTION(LINESTRING(-28 -25, -27.6
>> -25.5), ' .ST_AsText(ST_Segmentize(ST_GeomFromText('LINESTRING(-29
>> -27,-30 -29.7,-36 -31,-45 -33)'), 3857), 5)). ')');
>>
>> Just struggling to find an example online.  But given that, I'm just
>> about there.  Thanks again!
>>
>> - Derek
>>
>> On Wed, Nov 28, 2012 at 8:47 AM, Paul Ramsey <pramsey at opengeo.org> wrote:
>> > ST_Segmentize in geography will just segmentize along the great
>> > circle. You'll have to choose whether you want your model in geometry
>> > or geography. If geometry, then you can use Mercator as your
>> > projection (rhumb lines are then straight line) and use
>> > ST_Segmentize(geography) to convert your great circles into
>> > approximations in mercator.
>> > Or, you can use geography, and leave your great circle lines alone,
>> > but project your rhumb lines into geometry in mercator, st_segmentize
>> > them *there*, then convert htem back to geography.
>> > Clear as mud?
>> > P.
>> >
>> > On Wed, Nov 28, 2012 at 4:33 AM, Sandro Santilli <strk at keybit.net> wrote:
>> >> PostGIS-2.1 (in development) has an ST_Segmentize implementation for
>> >> "geography" type, which should help with rhumb lines.
>> >>
>> >> You may or may not need to segmentize depending on the operation you
>> >> want to do on those lines. Anyway it would be practical to use in your
>> >> SQL queries if you don't want to store the segmentization persistently.
>> >>
>> >> --strk;
>> >>
>> >> On Wed, Nov 28, 2012 at 01:39:09AM -0800, Derek Meyer wrote:
>> >>> My current project involves creating a spatial database of world-wide
>> >>> airspace data, where each known flight information region is a polygon
>> >>> containing boundaries that are a combination of great circle lines,
>> >>> rhumb lines, and arcs.
>> >>>
>> >>> It seems straight forward enough that these polys could be easily
>> >>> inserted into the database via ST_GeographyFromText fed with a WKT
>> >>> GEOMETRYCOLLECTION of these compound boundary types, but I'm wondering
>> >>> about how to deal with rhumb lines in such a case since the Geography
>> >>> functions, if I understand correctly, base everything around a round
>> >>> earth model and utilize great-circle by nature.
>> >>>
>> >>> Is there any way to explicitly declare a rhumb line in an insert query
>> >>> such as this?  I've seen some examples elsewhere where a temporary
>> >>> projection to 2D is utilized and then segmentized to
>> >>> render/interpolate coordinates for a linestring that would more
>> >>> accurately represent said rhumb line.  Is this still the accepted
>> >>> approach?  Practical?  If so, how would such an approach be
>> >>> implemented in context of the SQL query?
>> >>>
>> >>> Any info/suggestions welcome and appreciated.
>> >>>
>> >>> Thank you for your time,
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users


More information about the postgis-users mailing list