5

I have a problem transforming a linestring into a polygon. The error is:

ERROR: lwpoly_from_lwlines: shell must be closed

So I checked but firstpoint and endpoint are the same. I tried to use ST_makevalid and ST_RemoveRepeatedPoints but the problem was still there.

I finally found a workaround: I transform the geometry into text via st_astext and then I use st_geomfromtext and it works.

Does anyone undestand why I have to use this trick to transform my linestring into a polygon ?

You can make the test yourself:

select st_makepolygon('0102000020B46B00007D000000D89E591A2DD4284123D92354DF65F44013622E214AD42841E1B4E005AD65F4407A6EA1134AD42841F65E7C11AB65F440075C578C5CD4284157B4390E8B65F440043BFE335CD428412FC1A94F7E65F4405DA450CE5DD42841ED478A887B65F44040BD19E55DD42841C826F9D17E65F44040BD19E55DD42841C826F9D17E65F440C4500A195ED4284122D6BF8D7E65F4403BC8714D5ED42841EDF256667E65F440D14610825ED428410984EE5B7E65F440A3ACA5B65ED428417C38936E7E65F440E5E4F1EA5ED42841FE572E9E7E65F440F733B51E5FD42841A9DE85EA7E65F4401485B0515FD42841ACC33C537F65F4402EB7A5835FD42841AD6AD3D77F65F440A7E857B45FD42841483FA8778065F44082C18BE35FD42841FF79F8318165F440B4BB071160D42841900DE1058265F4404169943C60D42841B1BB5FF28265F440C3B7FC6560D42841BD4F54F68365F4401C310E8D60D42841F2FD81108565F440F43899B160D4284181E5903F8665F440BE4671D360D428419EB30F828765F440F91B6DF260D42841966575D68865F4407DF6660E61D42841C027233B8A65F44075BE3C2761D42841034F66AE8B65F440EE2FD03C61D428418E6A7A2E8D65F440BFFF064F61D42841396B8BB98E65F4408AFBCA5D61D42841E5DDB74D9065F440D1240A6961D428413B3613E99165F440E0C6B67061D42841E926A8899365F4408087C77461D428418A047B2D9565F4406172377561D4284157308CD29665F4401EFF057261D42841A087DA769865F440D76CE53D62D4284147AE9B129965F4403C855CA162D42841EB8B84369565F440BE839F9063D42841A41AF63B9B65F440944F8F2D60D42841A9BF5EE1BC65F4409F724C3E5FD42841F030EDDBB665F440B8B1D9A15FD4284192E7FAFEB265F44010035D635FD42841A0FEB3E6AC65F44010035D635FD428419FFEB3E6AC65F440473EFB305FD42841E25FBE58AD65F4409E88BDFD5ED42841E053DEAEAD65F44022ADE1C95ED4284149FEABE8AD65F4409835A6955ED4284126AAE105AE65F440111F4A615ED42841E81D5C06AE65F440F68D0C2D5ED42841E4C51AEAAD65F440E0812CF95DD4284104B53FB1AD65F440A289E8C55DD42841B07B0F5CAD65F440D6777E935DD4284120D5F0EAAC65F44051182B625DD42841772B6C5EAC65F440D1E629325DD4284143F32AB7AB65F44042C7B4035DD4284121DFF6F5AA65F440ECBF03D75CD4284183ECB81BAA65F440E9B54CAC5CD42841BB4A7829A965F4401F2CC3835CD428418F1D5920A865F4402605985D5CD42841F71C9B01A765F4405648F9395CD42841881398CEA565F4404F4013C14AD4284144F98216C465F440446E86B34AD42841EA961D22C265F440B2F336A62DD42841A0F99C7BF465F440B2F336A62DD42841A0F99C7BF465F440E87F7A942DD428413BE2D89CF565F440DF6451802DD42841B01EBBB3F665F44031ABD3692DD428415E39F7BEF765F440B0221C512DD42841AD9F4EBDF865F440784248362DD42841CD1D92ADF965F440C70578192DD428413048A38EFA65F440E4C5CDFA2CD42841F7D0755FFB65F44024116EDA2CD42841CCC7101FFC65F440617F7FB82CD42841A5C28FCCFC65F440EC832A952CD4284113EE2367FD65F4405E3D99702CD42841C90315EEFD65F4405E43F74A2CD428415126C260FE65F440A77271242CD42841CEA0A2BEFE65F44094B735FD2BD42841F0894607FF65F4405AD772D52BD428416449573AFF65F440493858AD2BD428410AFF9757FF65F4404EA915852BD4284188CBE55EFF65F440EF28DB5C2BD42841DEF93750FF65F44019ACD8342BD42841C609A02BFF65F440F1E43D0D2BD42841D79A49F1FE65F440FD093AE62AD4284186387AA1FE65F440D69DFBBF2AD428413B07913CFE65F440B937B09A2AD42841E95206C3FD65F4402C4D84762AD42841A7FF6A35FD65F44003FDA2532AD42841F0DC6794FC65F440EFDB35322AD428416ADCBCE0FB65F440F8C264122AD42841172D401BFB65F440BE89211129D42841FEEDB25FFC65F4405C76880F29D428414D81CC0EFC65F4401C7C61AA28D428411904568EFC65F440103FFF3528D428411D57237BE565F440C217269B28D42841E3C798FBE465F440F3C98A9928D4284188B9A4AAE465F44032C9C89129D42841E3DD9171E365F44032C9C89129D42841E4DD9171E365F440086EA1A729D4284126998763E265F4406683B9BF29D42841C4650462E165F4402267F4D929D428410D4B3A6EE065F4403EED32F629D4284156014B89DF65F440F48453142AD42841AC9946B4DE65F440996032342AD42841833A2AF0DD65F4402DA0A9552AD42841DCF2DE3DDD65F440577E91782AD4284150A5389EDC65F440AE7FC09C2AD428413E0CF511DC65F44006A40BC22AD4284155D8BA99DB65F440849946E82AD428417BEA1836DB65F44051F1430F2BD4284100AA85E7DA65F4409055D5362BD42841E7775EAEDA65F44077C0CB5E2BD42841F33FE78ADA65F4402AB4F7862BD42841E6274A7DDA65F440317329AF2BD42841725D9785DA65F4402E3931D72BD42841FE02C5A3DA65F440A673DFFE2BD428415B3BAFD7DA65F4408AFA04262CD4284167541821DB65F4403C48734C2CD428415F10A97FDB65F440E0B0FC712CD42841890DF1F2DB65F4409C9874962CD42841C54B677ADC65F440A1A8AFB92CD428415DCF6A15DD65F440A70284DB2CD42841526043C3DD65F440B272C9FB2CD428414C652283DE65F440D89E591A2DD4284121D92354DF65F440');

From binary to text and back:

select st_makepolygon(st_geomfromtext(st_astext('0102000020B46B00007D000000D89E591A2DD4284123D92354DF65F44013622E214AD42841E1B4E005AD65F4407A6EA1134AD42841F65E7C11AB65F440075C578C5CD4284157B4390E8B65F440043BFE335CD428412FC1A94F7E65F4405DA450CE5DD42841ED478A887B65F44040BD19E55DD42841C826F9D17E65F44040BD19E55DD42841C826F9D17E65F440C4500A195ED4284122D6BF8D7E65F4403BC8714D5ED42841EDF256667E65F440D14610825ED428410984EE5B7E65F440A3ACA5B65ED428417C38936E7E65F440E5E4F1EA5ED42841FE572E9E7E65F440F733B51E5FD42841A9DE85EA7E65F4401485B0515FD42841ACC33C537F65F4402EB7A5835FD42841AD6AD3D77F65F440A7E857B45FD42841483FA8778065F44082C18BE35FD42841FF79F8318165F440B4BB071160D42841900DE1058265F4404169943C60D42841B1BB5FF28265F440C3B7FC6560D42841BD4F54F68365F4401C310E8D60D42841F2FD81108565F440F43899B160D4284181E5903F8665F440BE4671D360D428419EB30F828765F440F91B6DF260D42841966575D68865F4407DF6660E61D42841C027233B8A65F44075BE3C2761D42841034F66AE8B65F440EE2FD03C61D428418E6A7A2E8D65F440BFFF064F61D42841396B8BB98E65F4408AFBCA5D61D42841E5DDB74D9065F440D1240A6961D428413B3613E99165F440E0C6B67061D42841E926A8899365F4408087C77461D428418A047B2D9565F4406172377561D4284157308CD29665F4401EFF057261D42841A087DA769865F440D76CE53D62D4284147AE9B129965F4403C855CA162D42841EB8B84369565F440BE839F9063D42841A41AF63B9B65F440944F8F2D60D42841A9BF5EE1BC65F4409F724C3E5FD42841F030EDDBB665F440B8B1D9A15FD4284192E7FAFEB265F44010035D635FD42841A0FEB3E6AC65F44010035D635FD428419FFEB3E6AC65F440473EFB305FD42841E25FBE58AD65F4409E88BDFD5ED42841E053DEAEAD65F44022ADE1C95ED4284149FEABE8AD65F4409835A6955ED4284126AAE105AE65F440111F4A615ED42841E81D5C06AE65F440F68D0C2D5ED42841E4C51AEAAD65F440E0812CF95DD4284104B53FB1AD65F440A289E8C55DD42841B07B0F5CAD65F440D6777E935DD4284120D5F0EAAC65F44051182B625DD42841772B6C5EAC65F440D1E629325DD4284143F32AB7AB65F44042C7B4035DD4284121DFF6F5AA65F440ECBF03D75CD4284183ECB81BAA65F440E9B54CAC5CD42841BB4A7829A965F4401F2CC3835CD428418F1D5920A865F4402605985D5CD42841F71C9B01A765F4405648F9395CD42841881398CEA565F4404F4013C14AD4284144F98216C465F440446E86B34AD42841EA961D22C265F440B2F336A62DD42841A0F99C7BF465F440B2F336A62DD42841A0F99C7BF465F440E87F7A942DD428413BE2D89CF565F440DF6451802DD42841B01EBBB3F665F44031ABD3692DD428415E39F7BEF765F440B0221C512DD42841AD9F4EBDF865F440784248362DD42841CD1D92ADF965F440C70578192DD428413048A38EFA65F440E4C5CDFA2CD42841F7D0755FFB65F44024116EDA2CD42841CCC7101FFC65F440617F7FB82CD42841A5C28FCCFC65F440EC832A952CD4284113EE2367FD65F4405E3D99702CD42841C90315EEFD65F4405E43F74A2CD428415126C260FE65F440A77271242CD42841CEA0A2BEFE65F44094B735FD2BD42841F0894607FF65F4405AD772D52BD428416449573AFF65F440493858AD2BD428410AFF9757FF65F4404EA915852BD4284188CBE55EFF65F440EF28DB5C2BD42841DEF93750FF65F44019ACD8342BD42841C609A02BFF65F440F1E43D0D2BD42841D79A49F1FE65F440FD093AE62AD4284186387AA1FE65F440D69DFBBF2AD428413B07913CFE65F440B937B09A2AD42841E95206C3FD65F4402C4D84762AD42841A7FF6A35FD65F44003FDA2532AD42841F0DC6794FC65F440EFDB35322AD428416ADCBCE0FB65F440F8C264122AD42841172D401BFB65F440BE89211129D42841FEEDB25FFC65F4405C76880F29D428414D81CC0EFC65F4401C7C61AA28D428411904568EFC65F440103FFF3528D428411D57237BE565F440C217269B28D42841E3C798FBE465F440F3C98A9928D4284188B9A4AAE465F44032C9C89129D42841E3DD9171E365F44032C9C89129D42841E4DD9171E365F440086EA1A729D4284126998763E265F4406683B9BF29D42841C4650462E165F4402267F4D929D428410D4B3A6EE065F4403EED32F629D4284156014B89DF65F440F48453142AD42841AC9946B4DE65F440996032342AD42841833A2AF0DD65F4402DA0A9552AD42841DCF2DE3DDD65F440577E91782AD4284150A5389EDC65F440AE7FC09C2AD428413E0CF511DC65F44006A40BC22AD4284155D8BA99DB65F440849946E82AD428417BEA1836DB65F44051F1430F2BD4284100AA85E7DA65F4409055D5362BD42841E7775EAEDA65F44077C0CB5E2BD42841F33FE78ADA65F4402AB4F7862BD42841E6274A7DDA65F440317329AF2BD42841725D9785DA65F4402E3931D72BD42841FE02C5A3DA65F440A673DFFE2BD428415B3BAFD7DA65F4408AFA04262CD4284167541821DB65F4403C48734C2CD428415F10A97FDB65F440E0B0FC712CD42841890DF1F2DB65F4409C9874962CD42841C54B677ADC65F440A1A8AFB92CD428415DCF6A15DD65F440A70284DB2CD42841526043C3DD65F440B272C9FB2CD428414C652283DE65F440D89E591A2DD4284121D92354DF65F440')));

Informations : PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (Ubuntu 4.8.2-16ubuntu6) 4.8.2, 64-bit. The geometry come from a dxf file imported into postgis with ogr2ogr.

  • I can reproduce the issue. What is odd is that the result from st_geomfromtext(st_astext('your_original_binary_geom')) is not the same than the original. Can you confirm? Look at some 50 first numbers from the beginning of binary geom. – user30184 Sep 8 '14 at 8:14
  • Could you share a dxf file which contains this single linestring? I am not good at reading binary strings but 01-02000020 may mean "little endian-Linestring M" while 02000000 that is created by as_text is probably of type "Linestring". You could make a new conversion with ogr2ogr and force the geometry with -nlt LINESTRING. – user30184 Sep 8 '14 at 8:58
5

In order to close a linestring, the first and last binary coordinates (i.e. WKB) need to be exactly equal. WKT cannot be relied on, since it is rounded/truncated to be misinterpreted by humans. While the start and end points for the example problem have the same WKT, they do not have the same WKB, and thus the linestring is not exactly closed, even when the two points are about 291 nanometres apart!

SELECT ST_IsClosed(ls),
  ST_Equals(ST_StartPoint(ls), ST_EndPoint(ls)),
  ST_AsText(ST_StartPoint(ls)) = ST_AsText(ST_EndPoint(ls)) AS WKT_equal,
  ST_AsBinary(ST_StartPoint(ls)) = ST_AsBinary(ST_EndPoint(ls)) AS WKB_equal,
  ST_Distance(ST_StartPoint(ls), ST_EndPoint(ls))
FROM (
  SELECT '0102000020B46B00007D000000D89E591A2DD4284123D92354DF65F44013622E214AD42841E1B4E005AD65F4407A6EA1134AD42841F65E7C11AB65F440075C578C5CD4284157B4390E8B65F440043BFE335CD428412FC1A94F7E65F4405DA450CE5DD42841ED478A887B65F44040BD19E55DD42841C826F9D17E65F44040BD19E55DD42841C826F9D17E65F440C4500A195ED4284122D6BF8D7E65F4403BC8714D5ED42841EDF256667E65F440D14610825ED428410984EE5B7E65F440A3ACA5B65ED428417C38936E7E65F440E5E4F1EA5ED42841FE572E9E7E65F440F733B51E5FD42841A9DE85EA7E65F4401485B0515FD42841ACC33C537F65F4402EB7A5835FD42841AD6AD3D77F65F440A7E857B45FD42841483FA8778065F44082C18BE35FD42841FF79F8318165F440B4BB071160D42841900DE1058265F4404169943C60D42841B1BB5FF28265F440C3B7FC6560D42841BD4F54F68365F4401C310E8D60D42841F2FD81108565F440F43899B160D4284181E5903F8665F440BE4671D360D428419EB30F828765F440F91B6DF260D42841966575D68865F4407DF6660E61D42841C027233B8A65F44075BE3C2761D42841034F66AE8B65F440EE2FD03C61D428418E6A7A2E8D65F440BFFF064F61D42841396B8BB98E65F4408AFBCA5D61D42841E5DDB74D9065F440D1240A6961D428413B3613E99165F440E0C6B67061D42841E926A8899365F4408087C77461D428418A047B2D9565F4406172377561D4284157308CD29665F4401EFF057261D42841A087DA769865F440D76CE53D62D4284147AE9B129965F4403C855CA162D42841EB8B84369565F440BE839F9063D42841A41AF63B9B65F440944F8F2D60D42841A9BF5EE1BC65F4409F724C3E5FD42841F030EDDBB665F440B8B1D9A15FD4284192E7FAFEB265F44010035D635FD42841A0FEB3E6AC65F44010035D635FD428419FFEB3E6AC65F440473EFB305FD42841E25FBE58AD65F4409E88BDFD5ED42841E053DEAEAD65F44022ADE1C95ED4284149FEABE8AD65F4409835A6955ED4284126AAE105AE65F440111F4A615ED42841E81D5C06AE65F440F68D0C2D5ED42841E4C51AEAAD65F440E0812CF95DD4284104B53FB1AD65F440A289E8C55DD42841B07B0F5CAD65F440D6777E935DD4284120D5F0EAAC65F44051182B625DD42841772B6C5EAC65F440D1E629325DD4284143F32AB7AB65F44042C7B4035DD4284121DFF6F5AA65F440ECBF03D75CD4284183ECB81BAA65F440E9B54CAC5CD42841BB4A7829A965F4401F2CC3835CD428418F1D5920A865F4402605985D5CD42841F71C9B01A765F4405648F9395CD42841881398CEA565F4404F4013C14AD4284144F98216C465F440446E86B34AD42841EA961D22C265F440B2F336A62DD42841A0F99C7BF465F440B2F336A62DD42841A0F99C7BF465F440E87F7A942DD428413BE2D89CF565F440DF6451802DD42841B01EBBB3F665F44031ABD3692DD428415E39F7BEF765F440B0221C512DD42841AD9F4EBDF865F440784248362DD42841CD1D92ADF965F440C70578192DD428413048A38EFA65F440E4C5CDFA2CD42841F7D0755FFB65F44024116EDA2CD42841CCC7101FFC65F440617F7FB82CD42841A5C28FCCFC65F440EC832A952CD4284113EE2367FD65F4405E3D99702CD42841C90315EEFD65F4405E43F74A2CD428415126C260FE65F440A77271242CD42841CEA0A2BEFE65F44094B735FD2BD42841F0894607FF65F4405AD772D52BD428416449573AFF65F440493858AD2BD428410AFF9757FF65F4404EA915852BD4284188CBE55EFF65F440EF28DB5C2BD42841DEF93750FF65F44019ACD8342BD42841C609A02BFF65F440F1E43D0D2BD42841D79A49F1FE65F440FD093AE62AD4284186387AA1FE65F440D69DFBBF2AD428413B07913CFE65F440B937B09A2AD42841E95206C3FD65F4402C4D84762AD42841A7FF6A35FD65F44003FDA2532AD42841F0DC6794FC65F440EFDB35322AD428416ADCBCE0FB65F440F8C264122AD42841172D401BFB65F440BE89211129D42841FEEDB25FFC65F4405C76880F29D428414D81CC0EFC65F4401C7C61AA28D428411904568EFC65F440103FFF3528D428411D57237BE565F440C217269B28D42841E3C798FBE465F440F3C98A9928D4284188B9A4AAE465F44032C9C89129D42841E3DD9171E365F44032C9C89129D42841E4DD9171E365F440086EA1A729D4284126998763E265F4406683B9BF29D42841C4650462E165F4402267F4D929D428410D4B3A6EE065F4403EED32F629D4284156014B89DF65F440F48453142AD42841AC9946B4DE65F440996032342AD42841833A2AF0DD65F4402DA0A9552AD42841DCF2DE3DDD65F440577E91782AD4284150A5389EDC65F440AE7FC09C2AD428413E0CF511DC65F44006A40BC22AD4284155D8BA99DB65F440849946E82AD428417BEA1836DB65F44051F1430F2BD4284100AA85E7DA65F4409055D5362BD42841E7775EAEDA65F44077C0CB5E2BD42841F33FE78ADA65F4402AB4F7862BD42841E6274A7DDA65F440317329AF2BD42841725D9785DA65F4402E3931D72BD42841FE02C5A3DA65F440A673DFFE2BD428415B3BAFD7DA65F4408AFA04262CD4284167541821DB65F4403C48734C2CD428415F10A97FDB65F440E0B0FC712CD42841890DF1F2DB65F4409C9874962CD42841C54B677ADC65F440A1A8AFB92CD428415DCF6A15DD65F440A70284DB2CD42841526043C3DD65F440B272C9FB2CD428414C652283DE65F440D89E591A2DD4284121D92354DF65F440'::geometry AS ls
) AS f;
-[ RECORD 1 ]---------------------
st_isclosed | f
st_equals   | f
wkt_equal   | t
wkb_equal   | f
st_distance | 2.91038304567337e-11

If you want to force-close a linestring, you can use a function to do this. Here's one called ST_ForceClosed, which you can use before ST_MakePolygon:

CREATE OR REPLACE FUNCTION ST_ForceClosed(geom geometry)
  RETURNS geometry AS
$BODY$BEGIN
  IF ST_IsClosed(geom) THEN
    RETURN geom;
  ELSIF GeometryType(geom) = 'LINESTRING' THEN
    SELECT ST_AddPoint(geom, ST_StartPoint(geom)) INTO geom;
  ELSIF GeometryType(geom) ~ '(MULTI|COLLECTION)' THEN
    -- Recursively deconstruct parts
    WITH parts AS (
      SELECT ST_ForceClosed(gd.geom) AS closed_geom FROM ST_Dump(geom) AS gd
    ) -- Reconstitute parts
    SELECT ST_Collect(closed_geom) INTO geom
    FROM parts;
  END IF;
  IF NOT ST_IsClosed(geom) THEN
    RAISE EXCEPTION 'Could not close geometry';
  END IF;
  RETURN geom;
END;$BODY$ LANGUAGE plpgsql IMMUTABLE COST 42;

You may also want to remove the extra precision points using ST_SnapToGrid E.g., assuming you are okay with nanometre precision, here are the number of points in the polygons compared:

SELECT
  ST_NumPoints(ST_ExteriorRing(
    ST_MakePolygon(ST_ForceClosed(ls))
  )) AS num_pts_in_orig,
  ST_NumPoints(ST_ExteriorRing(
    ST_MakePolygon(ST_SnapToGrid(ST_ForceClosed(ls), 0.000000001)
  ))) AS num_pts_in_snapped
FROM (
  SELECT '0102000020B46B00007D000000D89E591A2DD4284123D92354DF65F44013622E214AD42841E1B4E005AD65F4407A6EA1134AD42841F65E7C11AB65F440075C578C5CD4284157B4390E8B65F440043BFE335CD428412FC1A94F7E65F4405DA450CE5DD42841ED478A887B65F44040BD19E55DD42841C826F9D17E65F44040BD19E55DD42841C826F9D17E65F440C4500A195ED4284122D6BF8D7E65F4403BC8714D5ED42841EDF256667E65F440D14610825ED428410984EE5B7E65F440A3ACA5B65ED428417C38936E7E65F440E5E4F1EA5ED42841FE572E9E7E65F440F733B51E5FD42841A9DE85EA7E65F4401485B0515FD42841ACC33C537F65F4402EB7A5835FD42841AD6AD3D77F65F440A7E857B45FD42841483FA8778065F44082C18BE35FD42841FF79F8318165F440B4BB071160D42841900DE1058265F4404169943C60D42841B1BB5FF28265F440C3B7FC6560D42841BD4F54F68365F4401C310E8D60D42841F2FD81108565F440F43899B160D4284181E5903F8665F440BE4671D360D428419EB30F828765F440F91B6DF260D42841966575D68865F4407DF6660E61D42841C027233B8A65F44075BE3C2761D42841034F66AE8B65F440EE2FD03C61D428418E6A7A2E8D65F440BFFF064F61D42841396B8BB98E65F4408AFBCA5D61D42841E5DDB74D9065F440D1240A6961D428413B3613E99165F440E0C6B67061D42841E926A8899365F4408087C77461D428418A047B2D9565F4406172377561D4284157308CD29665F4401EFF057261D42841A087DA769865F440D76CE53D62D4284147AE9B129965F4403C855CA162D42841EB8B84369565F440BE839F9063D42841A41AF63B9B65F440944F8F2D60D42841A9BF5EE1BC65F4409F724C3E5FD42841F030EDDBB665F440B8B1D9A15FD4284192E7FAFEB265F44010035D635FD42841A0FEB3E6AC65F44010035D635FD428419FFEB3E6AC65F440473EFB305FD42841E25FBE58AD65F4409E88BDFD5ED42841E053DEAEAD65F44022ADE1C95ED4284149FEABE8AD65F4409835A6955ED4284126AAE105AE65F440111F4A615ED42841E81D5C06AE65F440F68D0C2D5ED42841E4C51AEAAD65F440E0812CF95DD4284104B53FB1AD65F440A289E8C55DD42841B07B0F5CAD65F440D6777E935DD4284120D5F0EAAC65F44051182B625DD42841772B6C5EAC65F440D1E629325DD4284143F32AB7AB65F44042C7B4035DD4284121DFF6F5AA65F440ECBF03D75CD4284183ECB81BAA65F440E9B54CAC5CD42841BB4A7829A965F4401F2CC3835CD428418F1D5920A865F4402605985D5CD42841F71C9B01A765F4405648F9395CD42841881398CEA565F4404F4013C14AD4284144F98216C465F440446E86B34AD42841EA961D22C265F440B2F336A62DD42841A0F99C7BF465F440B2F336A62DD42841A0F99C7BF465F440E87F7A942DD428413BE2D89CF565F440DF6451802DD42841B01EBBB3F665F44031ABD3692DD428415E39F7BEF765F440B0221C512DD42841AD9F4EBDF865F440784248362DD42841CD1D92ADF965F440C70578192DD428413048A38EFA65F440E4C5CDFA2CD42841F7D0755FFB65F44024116EDA2CD42841CCC7101FFC65F440617F7FB82CD42841A5C28FCCFC65F440EC832A952CD4284113EE2367FD65F4405E3D99702CD42841C90315EEFD65F4405E43F74A2CD428415126C260FE65F440A77271242CD42841CEA0A2BEFE65F44094B735FD2BD42841F0894607FF65F4405AD772D52BD428416449573AFF65F440493858AD2BD428410AFF9757FF65F4404EA915852BD4284188CBE55EFF65F440EF28DB5C2BD42841DEF93750FF65F44019ACD8342BD42841C609A02BFF65F440F1E43D0D2BD42841D79A49F1FE65F440FD093AE62AD4284186387AA1FE65F440D69DFBBF2AD428413B07913CFE65F440B937B09A2AD42841E95206C3FD65F4402C4D84762AD42841A7FF6A35FD65F44003FDA2532AD42841F0DC6794FC65F440EFDB35322AD428416ADCBCE0FB65F440F8C264122AD42841172D401BFB65F440BE89211129D42841FEEDB25FFC65F4405C76880F29D428414D81CC0EFC65F4401C7C61AA28D428411904568EFC65F440103FFF3528D428411D57237BE565F440C217269B28D42841E3C798FBE465F440F3C98A9928D4284188B9A4AAE465F44032C9C89129D42841E3DD9171E365F44032C9C89129D42841E4DD9171E365F440086EA1A729D4284126998763E265F4406683B9BF29D42841C4650462E165F4402267F4D929D428410D4B3A6EE065F4403EED32F629D4284156014B89DF65F440F48453142AD42841AC9946B4DE65F440996032342AD42841833A2AF0DD65F4402DA0A9552AD42841DCF2DE3DDD65F440577E91782AD4284150A5389EDC65F440AE7FC09C2AD428413E0CF511DC65F44006A40BC22AD4284155D8BA99DB65F440849946E82AD428417BEA1836DB65F44051F1430F2BD4284100AA85E7DA65F4409055D5362BD42841E7775EAEDA65F44077C0CB5E2BD42841F33FE78ADA65F4402AB4F7862BD42841E6274A7DDA65F440317329AF2BD42841725D9785DA65F4402E3931D72BD42841FE02C5A3DA65F440A673DFFE2BD428415B3BAFD7DA65F4408AFA04262CD4284167541821DB65F4403C48734C2CD428415F10A97FDB65F440E0B0FC712CD42841890DF1F2DB65F4409C9874962CD42841C54B677ADC65F440A1A8AFB92CD428415DCF6A15DD65F440A70284DB2CD42841526043C3DD65F440B272C9FB2CD428414C652283DE65F440D89E591A2DD4284121D92354DF65F440'::geometry AS ls
) AS f;
-[ RECORD 1 ]------+----
num_pts_in_orig    | 126
num_pts_in_snapped | 121
  • Great answer but I do not still quite understand what happens here. The last 8+8 bytes of the WKB that was created by GDAL are D89E591A2DD4284123D92354DF65F440. Exactly same bytes can be found starting from place 27 in the binary string. I feel that the real problem is in the bytes before "D89E..." For the GDAL version they are 0102000020B46B00007D000000 while the geomfromtext version has 01020000007D000000. GDAL announced different geometry type but what mean the additional bytes in places 11-18: "B46B0000"??? – user30184 Sep 8 '14 at 10:46
  • 1
    Mike T was totally right and the definite explanation for the remaining unclear bytes is available in gdal-dev mailing list lists.osgeo.org/pipermail/gdal-dev/2014-September/040017.html. – user30184 Sep 8 '14 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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