[postgis-users] ST_AsGeoJson output geometry type not the same as input

Belén Cálcena belen.calcena at merit.com.py
Wed Sep 3 12:48:25 PDT 2014


Please 

 

Please get me out of the mailing list

 

thank you very much

 

Belén Cálcena

MERIT Paraguay S.A.

RF. Engineer

Rivarola Matto 5837 c/ R.I. 6 Boquerón

Asuncion, Paraguay

Landline/FAX: +595-21-606-691/92

Cellular: +595-994-355-735

LOGO 2

 

From: Max Demars [mailto:burton449geo at gmail.com] 
Sent: Wednesday, September 03, 2014 3:45 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] ST_AsGeoJson output geometry type not the same as input

 

Thank you very much, this is what I was looking for.

-Cheers

-Max Demars

 

On Wed, Sep 3, 2014 at 3:55 AM, Sandro Santilli <strk at keybit.net> wrote:

On Tue, Sep 02, 2014 at 01:19:55PM -0400, Max Demars wrote:
> Hi list,
>
> I am using postgis to split a multipolygon feature by a linestring. Both
> feature are geojson inputs.
>
> However the outputs returns a geojson that is a geocollection of two
> polygon features. In fact this is correct, but for consistency I would like
> to keep the the splitted features into a single Multipolygon (even if there
> is only one linear ring in it). Is it possible?

Possible, but such a multipolygon would be invalid.


> This is my query:
>
> SQLQuery = '''SELECT
> ST_AsGeoJSON(ST_Split(ST_GeomFromGeoJSON('%s'),ST_GeomFromGeoJSON('%s')))::json
> As f''' % (feature,blade)

Make it:

SELECT
ST_AsGeoJSON(
 ST_Collect(geom) FROM (
  SELECT (
    ST_Dump(
      ST_Split(ST_GeomFromGeoJSON('%s'), ST_GeomFromGeoJSON('%s'))
    )
  ).geom
 ) foo
)::json As f

ST_Collect will create a MULTIPOLYGON if all inputs are of the POLYGON type.

--strk;

 ()  ASCII ribbon campaign  --  Keep it simple !
 /\  http://strk.keybit.net/rants/ascii_mails.txt
_______________________________________________
postgis-users mailing list
postgis-users at lists.osgeo.org
http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-users




-- 

Stack Overflow: http://stackoverflow.com/users/1914034/burton449

GIS Overflow: http://gis.stackexchange.com/users/14426/burton449

LastFm: http://www.lastfm.fr/user/burton449

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140903/71b6df69/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 6054 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20140903/71b6df69/attachment.jpg>


More information about the postgis-users mailing list