2

I'm trying to make this data to geometry, but for some reason postgresql returns not readable values. I need latlng.... I can't use that value to draw marker at all.

what am i missing here?

please help.

postgresql v. 11

insert into area(latlng) values('0101000000A0ABA80D249D024100EC624219AA0B41'::geometry);

select st_asgeojson(latlng) from area;

returns

"{""type"":""Point"",""coordinates"":[152484.50666937,226627.157415241]}"

----------------------------------------- added

more queries are added. they always return same value. I'm started thinking the value that I provided from data team, might be wrong...('0101000000A0ABA80D249D024100EC624219AA0B41')

select ST_AsText('0101000000A0ABA80D249D024100EC624219AA0B41'); "POINT(152484.50666936953 226627.157415241)"

select st_setsrid(st_asgeojson('0101000000A0ABA80D249D024100EC624219AA0B41')::geometry, 4326);

enter image description here

select st_transform(st_setsrid(st_asgeojson('0101000000A0ABA80D249D024100EC624219AA0B41'::geometry), 4326), 3857); enter image description here

8
  • A large part of GIS is the projection that the data is encoded in. Can you do select st_srid(latlng) from area; and add it. You may need to use st_transform to tranform it into a different projection (e.g. WGS84, which is identified as srid 4326, is probably lat/lng). Probably searching up a bunch of these terms might help. ;-) Commented Aug 24, 2023 at 3:43
  • @GregHNZ Hey!! Thank you so much for the comment! I've tested with your suggestion and then now it returns ERROR: transform: Invalid coordinate(2049) ... should I contact with data team...? Commented Aug 24, 2023 at 5:28
  • @ChaehwaRyu perhaps you've mistakenly created the coordinates as lat long? It should be long lat (x,y) Commented Aug 24, 2023 at 6:04
  • @JimJones Thanks for the opinion! but i've got that data from the data team. I didn't make it. I have zero idea how they converted. i'm just trying to convert it back to latlng(lnglat). I guess this one is just poor as other datasets they provided. I'll check it out!! :) have a great day! Commented Aug 24, 2023 at 6:36
  • 1
    @mlinth (pedantic note) it is not entirely accurate: dbfiddle.uk/A7DQSyQt :) Commented Aug 29, 2023 at 13:14

1 Answer 1

2

Your input value is geography and not geometry. See below

select st_astext('0101000000A0ABA80D249D024100EC624219AA0B41'::geography);
-- POINT(-155.4933306304738 -7.157415241003036)

select postgis_version();
-- 3.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

In short geography is more accurate but resource intensive to query. geometry is the 99% good enough version of geography

Info: https://postgis.net/documentation/faq/geometry-or-geography/

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry for late, super thanks. it works :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.