[postgis-users] Re: Testing for empty feature
Sean Fulton
seanasy at gmail.com
Sun Jul 6 13:43:52 PDT 2008
ST_IsEmpty doesn't seem to work for me and I don't see the MultiPolygon
being converted to a GeometryCollection.
civics=# SELECT astext(wkb_geometry) FROM scale150000 LIMIT 1;
astext
------------------------
MULTIPOLYGON(( EMPTY))
(1 row)
civics=# SELECT ST_IsEmpty(wkb_geometry) FROM scale150000 LIMIT 1;
st_isempty
------------
f
(1 row)
ST_NPOINTS works. It seems like there should be a more direct way.
Sean
On 2008-07-04 12:03:33 -0400, Martin Davis <mbdavis at refractions.net> said:
> Actually JTS/GEOS handle empty MultiPolygons just fine. I don't know why
> the MULTIPOLYGON EMPTY is being converted to a general
> GeometryCollection - I think this must be something that is being done
> by PostGIS.
>
> Seems like the answer is to use ST_IsEmpty. Doing text comparisons is
> always going to be risky.
>
> Kevin Neufeld wrote:
>> I believe that an empty multipolygon is converted into an empty
>> geometrycollection in JTS and hence PostGIS.
>>
>>
>> postgis=# SELECT ST_AsText('MULTIPOLYGON EMPTY'::geometry);
>> st_astext
>> --------------------------
>> GEOMETRYCOLLECTION EMPTY
>> (1 row)
>>
>>
>> postgis=# SELECT ST_IsEmpty('MULTIPOLYGON EMPTY'::geometry);
>> st_isempty
>> ------------
>> t
>> (1 row)
>>
>> Alternatively, I suppose you could get the number of points in the geometry.
>>
>> postgis=# SELECT ST_NPoints('MULTIPOLYGON EMPTY'::geometry);
>> st_npoints
>> ------------
>> 0
>> (1 row)
>>
>>
>> Cheers,
>> Kevin
>>
>>
>> Sean Fulton wrote:
>>
>>> How do I test for an empty feature such as 'MULTIPOLYGON(( EMPTY ))' ?
>>>
>>> IsEmpty seems to work only for collections.
>>>
>>> astext(wkb_geometry) = 'MULTIPOLYGON(( EMPTY ))' doesn't seem to work.
>>>
>>> Thanks,
>>>
>>> Sean
>>>
>>>
>>> _______________________________________________
>>> 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