Converting “type”:“MultiLineString”,“coordinates”:[[[x1,y1],[x2,y2]]] to geography column using PostGIS?Casting a Geography type in PostGISNewbie PostGIS Geometry and Multilinestring ClarificationPostGIS convert geography(Point,4326) to GPSHow to import PostGIS layer with geography type to QGIS?How to get Lon/Lat values from the postgis raster type columnInvalid Input Syntax for Type Double Precision in PostGIS?Postgis How to populate column with geography data from geometric data?Get latitude and longitude of a geography columnLat-Long values get rounded off when stored in a column type Geography in postgresProblem to convert geometry to coordinates of geometry(MultiLineString) data
Why do airports remove/realign runways?
Converting "type":"MultiLineString","coordinates":[[[x1,y1],[x2,y2]]] to geography column using PostGIS?
Deck of Cards with Shuffle and Sort functionality
Write a function
Can Jimmy hang on his rope?
Four ships at the ocean with the same distance
How does one acquire an undead eyeball encased in a gem?
Is it possible for a character at any level to cast all 44 Cantrips in one week without Magic Items?
US citizen traveling with Peruvian passport
Where are the Wazirs?
Gory anime with pink haired girl escaping an asylum
Is this really the Saturn V computer only, or are there other systems here as well?
How do ballistic trajectories work in a ring world?
Moving millions of files to a different directory with specfic name patterns
Category-theoretic treatment of diffs, patches and merging?
How do resistors generate different heat if we make the current fixed and changed the voltage and resistance? Notice the flow of charge is constant
Mtg creature spells, instants, priority?
Chilling water in copper vessel
Was it ever illegal to name a pig "Napoleon" in France?
How can I know how much authority/decision making power etc I have as an employee?
Can a landlord force all residents to use the landlord's in-house debit card accounts?
Appropriate conduit for several data cables underground over 300' run
How do I explain that I don't want to maintain old projects?
Is there a formal/better word than "skyrocket" for the given context?
Converting “type”:“MultiLineString”,“coordinates”:[[[x1,y1],[x2,y2]]] to geography column using PostGIS?
Casting a Geography type in PostGISNewbie PostGIS Geometry and Multilinestring ClarificationPostGIS convert geography(Point,4326) to GPSHow to import PostGIS layer with geography type to QGIS?How to get Lon/Lat values from the postgis raster type columnInvalid Input Syntax for Type Double Precision in PostGIS?Postgis How to populate column with geography data from geometric data?Get latitude and longitude of a geography columnLat-Long values get rounded off when stored in a column type Geography in postgresProblem to convert geometry to coordinates of geometry(MultiLineString) data
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a Postgresql table with a text column that has data like the below.
"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]
I have added a new column to the table with type Geography and I would like to move this multilinestring data to the new geography column.
I need to find the centroid of the mulitilinestring in the form of lat/lng so that distance can be calculated from a give address. The table has around 139k rows.
postgis
New contributor
add a comment |
I have a Postgresql table with a text column that has data like the below.
"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]
I have added a new column to the table with type Geography and I would like to move this multilinestring data to the new geography column.
I need to find the centroid of the mulitilinestring in the form of lat/lng so that distance can be calculated from a give address. The table has around 139k rows.
postgis
New contributor
add a comment |
I have a Postgresql table with a text column that has data like the below.
"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]
I have added a new column to the table with type Geography and I would like to move this multilinestring data to the new geography column.
I need to find the centroid of the mulitilinestring in the form of lat/lng so that distance can be calculated from a give address. The table has around 139k rows.
postgis
New contributor
I have a Postgresql table with a text column that has data like the below.
"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]
I have added a new column to the table with type Geography and I would like to move this multilinestring data to the new geography column.
I need to find the centroid of the mulitilinestring in the form of lat/lng so that distance can be calculated from a give address. The table has around 139k rows.
postgis
postgis
New contributor
New contributor
edited 4 hours ago
PolyGeo♦
54.5k17 gold badges84 silver badges255 bronze badges
54.5k17 gold badges84 silver badges255 bronze badges
New contributor
asked 8 hours ago
Venkat PolisettiVenkat Polisetti
83 bronze badges
83 bronze badges
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can use ST_FromGeoJson
to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
ex:
select st_AsText(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]'));
st_astext
------------------------------------------------------------------------------------
MULTILINESTRING((-122.995882414 44.0576694170001,-122.998182101 44.0576887840001))
with the cast:
select st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography;
... and the centroid
select st_centroid(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography);
From a column:
SELECT st_centroid(st_geomFromGeoJson(my_geoJson_column)::geography)
FROM myTable;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "79"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Venkat Polisetti is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f328020%2fconverting-typemultilinestring-coordinatesx1-y1-x2-y2-to-geogr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use ST_FromGeoJson
to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
ex:
select st_AsText(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]'));
st_astext
------------------------------------------------------------------------------------
MULTILINESTRING((-122.995882414 44.0576694170001,-122.998182101 44.0576887840001))
with the cast:
select st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography;
... and the centroid
select st_centroid(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography);
From a column:
SELECT st_centroid(st_geomFromGeoJson(my_geoJson_column)::geography)
FROM myTable;
add a comment |
You can use ST_FromGeoJson
to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
ex:
select st_AsText(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]'));
st_astext
------------------------------------------------------------------------------------
MULTILINESTRING((-122.995882414 44.0576694170001,-122.998182101 44.0576887840001))
with the cast:
select st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography;
... and the centroid
select st_centroid(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography);
From a column:
SELECT st_centroid(st_geomFromGeoJson(my_geoJson_column)::geography)
FROM myTable;
add a comment |
You can use ST_FromGeoJson
to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
ex:
select st_AsText(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]'));
st_astext
------------------------------------------------------------------------------------
MULTILINESTRING((-122.995882414 44.0576694170001,-122.998182101 44.0576887840001))
with the cast:
select st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography;
... and the centroid
select st_centroid(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography);
From a column:
SELECT st_centroid(st_geomFromGeoJson(my_geoJson_column)::geography)
FROM myTable;
You can use ST_FromGeoJson
to convert the text to a geometry, then you would cast the result to the desired geography format. At last, you can use ST_Centroid
ex:
select st_AsText(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]'));
st_astext
------------------------------------------------------------------------------------
MULTILINESTRING((-122.995882414 44.0576694170001,-122.998182101 44.0576887840001))
with the cast:
select st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography;
... and the centroid
select st_centroid(st_geomFromGeoJson('"type":"MultiLineString","coordinates":[[[-122.995882414,44.05766941700006],[-122.99818210099994,44.05768878400005]]]')::geography);
From a column:
SELECT st_centroid(st_geomFromGeoJson(my_geoJson_column)::geography)
FROM myTable;
answered 7 hours ago
JGHJGH
15k2 gold badges14 silver badges39 bronze badges
15k2 gold badges14 silver badges39 bronze badges
add a comment |
add a comment |
Venkat Polisetti is a new contributor. Be nice, and check out our Code of Conduct.
Venkat Polisetti is a new contributor. Be nice, and check out our Code of Conduct.
Venkat Polisetti is a new contributor. Be nice, and check out our Code of Conduct.
Venkat Polisetti is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f328020%2fconverting-typemultilinestring-coordinatesx1-y1-x2-y2-to-geogr%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown