Home > Mobile >  How can I unify my geometry with geojson?
How can I unify my geometry with geojson?

Time:08-06

I want to unify with postgis my geometry with geojson but it doesn't work

select ST_AsGeoJSON(ST_Union(geo)) from (       
    select ST_Buffer(ST_Transform(geom,4326)::geography,500)::geometry as geo FROM table_data

      Union all

    select ST_Buffer(ST_Transform(ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[4.7718133999999983,45.751034700379336],[4.7732161999999985,45.753077900379047],[4.7801820999999993,45.754600200378832],[4.7821356999999995,45.754461600378846],[4.7820908999999983,45.756529400378554],[4.7852063999999981,45.758854600378235],[4.7870810999999991,45.765387900377306],[4.7892927999999992,45.766544300377156],[4.7905733999999986,45.767903400376952],[4.7912280999999988,45.771446600376443],[4.7924920999999987,45.773515700376151],[4.795157399999999,45.775803000375831],[4.7921674999999988,45.779246400375342],[4.7909021999999979,45.7822510003749],[4.7921700999999981,45.785207500374476],[4.7919013999999995,45.786570700374284],[4.7857526999999989,45.78585010037439],[4.7849289999999982,45.788069200374082],[4.7883277999999985,45.789775100373831],[4.7905100999999988,45.79089470037367],[4.7934197999999979,45.789282500373886],[4.7975291999999987,45.789847200373806],[4.7971985999999989,45.791482600373584],[4.8013753999999986,45.791290000373614],[4.8022111999999995,45.792041100373517],[4.8070630999999988,45.789003600373945],[4.8096090999999985,45.792440400373437],[4.8139945999999991,45.7942379003732],[4.816270799999999,45.7970563003728],[4.8166826999999994,45.798412100372595],[4.8184066999999988,45.79930800037247],[4.8196049999999984,45.799385500372459],[4.8203043999999995,45.802155100372055],[4.823837499999998,45.802009300372085],[4.8241582999999979,45.804528900371722],[4.827171599999998,45.804712700371695],[4.8321631999999983,45.806999500371354],[4.8322759999999985,45.805557200371574],[4.8345430999999985,45.804307100371751],[4.8369834999999979,45.808262800371182],[4.8389672999999993,45.803852500371804],[4.8412469999999983,45.803216700371905],[4.8405863999999994,45.801963500372075],[4.8371177999999979,45.798335300372614],[4.8335112999999978,45.796853900372838],[4.8291917999999994,45.796213900372919],[4.8225897999999985,45.792472100373438],[4.8189186999999993,45.789726100373841],[4.8223407999999992,45.787745800374125],[4.8235941999999978,45.7843982003746],[4.8331413999999988,45.781757600374981],[4.8381035999999975,45.782485600374869],[4.8412973999999993,45.779434900375307],[4.843032499999997,45.778919000375382],[4.8456883999999993,45.782278300374905],[4.8480465999999982,45.7843718003746],[4.8512447999999981,45.786034900374361],[4.8553270999999993,45.787138700374207],[4.8598280999999979,45.787021300374228],[4.8586979999999986,45.777832200375535],[4.8583621999999984,45.7724259003763],[4.8611271999999985,45.771875100376384],[4.8630206999999981,45.769191400376755],[4.8653019999999989,45.768296700376887],[4.8680070999999989,45.766351800377159],[4.8718481999999979,45.761265000377911],[4.8744195999999986,45.760525100378004],[4.8737345999999988,45.758743700378254],[4.8765671999999993,45.758236600378311],[4.8760987999999976,45.75532090037872],[4.8832563999999987,45.754329400378872],[4.8935626999999995,45.753986900378919],[4.8983773999999993,45.752922300379076],[4.8972099999999994,45.75020600037945],[4.8966669999999981,45.747279000379848],[4.894829999999998,45.743669000380365],[4.8897088999999969,45.735086900381567],[4.8877978999999989,45.730775400382178],[4.8867335999999986,45.729315100382379],[4.8870075999999978,45.726124800382827],[4.8875538999999995,45.720357300383625],[4.8860551999999986,45.721490600383468],[4.8808419999999986,45.721734600383414],[4.8623578999999983,45.726914700382714],[4.8598145999999973,45.730704900382186],[4.8536965999999984,45.729738900382323],[4.854488599999998,45.718893100383831],[4.849740999999999,45.718796500383839],[4.837449799999999,45.718613000383861],[4.8381020999999986,45.713631300384556],[4.8404877999999982,45.707959700385359],[4.8376821999999988,45.707366600385427],[4.8330493999999984,45.709996800385049],[4.828008699999998,45.711609300384836],[4.8237961999999994,45.714307600384458],[4.8224713999999995,45.715919700384241],[4.8209415999999985,45.7190690003838],[4.8202529999999983,45.720487800383616],[4.8186822999999981,45.726595700382759],[4.817820499999999,45.726491900382776],[4.816876699999999,45.730396400382212],[4.8147679999999982,45.731819900382021],[4.8141234999999982,45.733487300381782],[4.8130294999999981,45.739802800380915],[4.8135772999999995,45.743391600380406],[4.8161482999999983,45.74727460037986],[4.8183329999999991,45.749075700379606],[4.814626099999999,45.749650600379532],[4.813400399999999,45.748004800379753],[4.8025329999999986,45.75167040037924],[4.7995818999999988,45.7505287003794],[4.7945228999999978,45.749232600379592],[4.7835874999999994,45.744245600380275],[4.778781399999998,45.747540400379812],[4.7775823999999991,45.747168900379876],[4.7755830999999986,45.74810970037975],[4.7718133999999983,45.751034700379336]]]}'),4326)::geography,0)::geometry as geo) t

But i have this error

Input geometry has unknown (0) SRID

CodePudding user response:

Some geometries in table_data.geom have no declared projection, so you can't reproject them.

You would first have to set the current projection (3857 in the example below), then you can transform it.

select st_transform('point(0 0)',4326);
--> ERROR:  ST_Transform: Input geometry has unknown (0) SRID

select st_transform(ST_SetSRID('point(0 0)'::geometry,3857),4326);
--> 0101000020E610000000000000000000000000000000000000

Alternatively, you can modify your table to force every geometry to have the same projection: doc

  • Related