PostGIS GeoJson Query Not Validating












2














I am using the following query to create a GeoJson response:



SELECT json_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT json_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(ST_ForcePolygonCW(wkb_geometry))::json,
'properties', to_jsonb(row) - 'id' - 'wkb_geometry'
) AS feature
FROM (SELECT * FROM gis_states LIMIT 1) AS row
) AS features


The resulting data-set (https://pastebin.com/hvFQXUTr) does not validate at http://geojsonlint.com, even though I am using ST_ForcePolygonCW:




Line 1: Polygons and MultiPolygons should follow the right-hand rule




Any suggestions on how to fix this?










share|improve this question
























  • Related: gis.stackexchange.com/questions/259944/…
    – RoVo
    Dec 19 '18 at 15:07
















2














I am using the following query to create a GeoJson response:



SELECT json_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT json_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(ST_ForcePolygonCW(wkb_geometry))::json,
'properties', to_jsonb(row) - 'id' - 'wkb_geometry'
) AS feature
FROM (SELECT * FROM gis_states LIMIT 1) AS row
) AS features


The resulting data-set (https://pastebin.com/hvFQXUTr) does not validate at http://geojsonlint.com, even though I am using ST_ForcePolygonCW:




Line 1: Polygons and MultiPolygons should follow the right-hand rule




Any suggestions on how to fix this?










share|improve this question
























  • Related: gis.stackexchange.com/questions/259944/…
    – RoVo
    Dec 19 '18 at 15:07














2












2








2







I am using the following query to create a GeoJson response:



SELECT json_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT json_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(ST_ForcePolygonCW(wkb_geometry))::json,
'properties', to_jsonb(row) - 'id' - 'wkb_geometry'
) AS feature
FROM (SELECT * FROM gis_states LIMIT 1) AS row
) AS features


The resulting data-set (https://pastebin.com/hvFQXUTr) does not validate at http://geojsonlint.com, even though I am using ST_ForcePolygonCW:




Line 1: Polygons and MultiPolygons should follow the right-hand rule




Any suggestions on how to fix this?










share|improve this question















I am using the following query to create a GeoJson response:



SELECT json_build_object(
'type', 'FeatureCollection',
'features', jsonb_agg(feature)
)
FROM (
SELECT json_build_object(
'type', 'Feature',
'id', id,
'geometry', ST_AsGeoJSON(ST_ForcePolygonCW(wkb_geometry))::json,
'properties', to_jsonb(row) - 'id' - 'wkb_geometry'
) AS feature
FROM (SELECT * FROM gis_states LIMIT 1) AS row
) AS features


The resulting data-set (https://pastebin.com/hvFQXUTr) does not validate at http://geojsonlint.com, even though I am using ST_ForcePolygonCW:




Line 1: Polygons and MultiPolygons should follow the right-hand rule




Any suggestions on how to fix this?







postgis geojson






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 19 '18 at 22:56









PolyGeo

53.2k1779238




53.2k1779238










asked Dec 19 '18 at 15:00









mike.bronner

1739




1739












  • Related: gis.stackexchange.com/questions/259944/…
    – RoVo
    Dec 19 '18 at 15:07


















  • Related: gis.stackexchange.com/questions/259944/…
    – RoVo
    Dec 19 '18 at 15:07
















Related: gis.stackexchange.com/questions/259944/…
– RoVo
Dec 19 '18 at 15:07




Related: gis.stackexchange.com/questions/259944/…
– RoVo
Dec 19 '18 at 15:07










1 Answer
1






active

oldest

votes


















3














OK, so the documentation (https://postgis.net/docs/ST_ForceRHR.html) states that ST_ForcePolygonCW is a synonym of ST_ForceRHR(). However, I wonder if the linter at http://geojsonlint.com/ is working properly, or perhaps the error is too ambiguous, as I got it to render correctly by using ST_ForcePolygonCCW, which is the opposite.






share|improve this answer

















  • 2




    The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
    – dbaston
    Dec 19 '18 at 19:04











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f306567%2fpostgis-geojson-query-not-validating%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









3














OK, so the documentation (https://postgis.net/docs/ST_ForceRHR.html) states that ST_ForcePolygonCW is a synonym of ST_ForceRHR(). However, I wonder if the linter at http://geojsonlint.com/ is working properly, or perhaps the error is too ambiguous, as I got it to render correctly by using ST_ForcePolygonCCW, which is the opposite.






share|improve this answer

















  • 2




    The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
    – dbaston
    Dec 19 '18 at 19:04
















3














OK, so the documentation (https://postgis.net/docs/ST_ForceRHR.html) states that ST_ForcePolygonCW is a synonym of ST_ForceRHR(). However, I wonder if the linter at http://geojsonlint.com/ is working properly, or perhaps the error is too ambiguous, as I got it to render correctly by using ST_ForcePolygonCCW, which is the opposite.






share|improve this answer

















  • 2




    The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
    – dbaston
    Dec 19 '18 at 19:04














3












3








3






OK, so the documentation (https://postgis.net/docs/ST_ForceRHR.html) states that ST_ForcePolygonCW is a synonym of ST_ForceRHR(). However, I wonder if the linter at http://geojsonlint.com/ is working properly, or perhaps the error is too ambiguous, as I got it to render correctly by using ST_ForcePolygonCCW, which is the opposite.






share|improve this answer












OK, so the documentation (https://postgis.net/docs/ST_ForceRHR.html) states that ST_ForcePolygonCW is a synonym of ST_ForceRHR(). However, I wonder if the linter at http://geojsonlint.com/ is working properly, or perhaps the error is too ambiguous, as I got it to render correctly by using ST_ForcePolygonCCW, which is the opposite.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 19 '18 at 15:05









mike.bronner

1739




1739








  • 2




    The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
    – dbaston
    Dec 19 '18 at 19:04














  • 2




    The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
    – dbaston
    Dec 19 '18 at 19:04








2




2




The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
– dbaston
Dec 19 '18 at 19:04




The problem is that "Right-Hand-Rule" isn't a very useful term in GIS. Some GIS software (e.g., PostGIS) uses it to refer mean that the interior of a boundary is to your right as you walk around it (clockwise orientation). In most other contexts, it refers to the direction your fingers curl when the thumb of your right hand is pointing towards your head (counterclockwise orientation).
– dbaston
Dec 19 '18 at 19:04


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f306567%2fpostgis-geojson-query-not-validating%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

Morgemoulin

Scott Moir

Souastre