Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using PostGIS 2.0.0 and would like to store a GML Surface in a way that allows calculating intersections between that surface and various points and lines. In my case, the Surface will have one PolygonPatch with no interior rings and an exterior ring which may be a LineStringSegment, a Geodesic, an Arc or a Circle. The distances can be in the order of tens to hundreds of miles. I see that PostGIS has CIRCULARSTRING and CURVEPOLYGON, which seem to be a good way of storing an Arc, except that they're not supported by the geography type, only geometry. What would be the best way to store this? (I'm quite new to PostGIS and GIS in general, so it's entirely possible I'm missing something obvious.)

share|improve this question
You can store GML in postgis as is.… – Mapperz Nov 3 '11 at 13:52
Some explanation here about PostGIS's geometry and geography types… – canisrufus Nov 3 '11 at 20:43


You can store your GML features as a PostGIS Geometry datatype by using the ST_GeomFromGML function which will convert your GML to the geometry datatype. FYI: There are similar functions for KML, WKT, and so on.

just do something like:

INSERT into myTable (mygeomField) values (ST_GeomFromGML('
    <gml:LineString srsName="EPSG:4269">
            -71.16028,42.258729 -71.160837,42.259112 -71.161143,42.25932

Once you have it in the geometry field you can do all the fun intersects and stuff you want to do in PostGIS

Then you can spit your result back out in GML format using ST_AsGML

EDIT #1 I believe you're looking for:


I'm using "POSTGIS="1.5.2" (older version than you) and the following statement works just fine:

select ST_GeomFromText('CIRCULARSTRING(220268 150415,220227 150505,220227 150406)')

You have to use a combination of functions to get what you need.

distance_spheroid does not support CIRCULARSTRING because it takes in the geometry data types.

Please add an EDIT to your original question with a piece of sample GML you are having problems with and i will write out the statements for you.

share|improve this answer
Thanks, but importing from GML isn't really the core problem. The main question is around how to store the data in a way that allows accurate calculations. As I understand, the geometry type wouldn't work well for that, since it's based on a plane, and the geography type doesn't support curves. – EM0 Nov 4 '11 at 1:35
@EM: Check my EDIT#1 – CaptDragon Nov 4 '11 at 16:37
Thanks, tried those, but unfortunately they don't support CIRCULARSTRINGs. – EM0 Nov 7 '11 at 1:55
@EM: Check my EDIT #2 – CaptDragon Nov 7 '11 at 16:38
Posted - thanks for your help on this. – EM0 Nov 25 '11 at 10:56

In the end I gave up on storing the "exact" arc or circle. When importing a GML Arc (which is defined by 3 points on the arc) I temporarily create a geometry CIRCULARSTRING, then convert it to geography, like this:

ST_RemoveRepeatedPoints(ST_CurveToLine(ST_GeomFromText('CIRCULARSTRING(...)', 4326)))::geography

When importing a GML ArcByCenterPoint (which is defined by the centre point, radius and start and end angles) I approximate it directly by projecting points at 1 degree intervals from the start angle to the end angle. This is done on a sphere, not spheroid, so it's not entirely accurate, but there are PostGIS tickets to implement azimuth and point projection for the geography type. Same for a circle.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.