1

I am wondering if there is a way to apply a translation in coordinates for a GeoJSON export. Currently, there are negative coordinate values in my export, which I cannot have. I am trying to use this GeoJSON data to create a map in javascript, and I consulted the developers of the javascript library and was told that if my x values were translated 160, making them positive, the map would display correctly. Is there an easy way to translate these values in the export or possibly do this with an expression? I am very new to QGIS so I am unsure how to approach this problem.

Basically, I want to change values like this

[ -160.07380334546815, 22.004177347957729 ],

to this

[ 0.07380334546815, 22.004177347957729 ],
2

I'm not sure who you consulted, but this doesn't seem like great advice. The problem seems to be not one of negative values but more the order of x and y co-ordinates. A latitude (y) can only be in the range of -90 to +90. Longitude (x) can be -180 to +180, broadly speaking. These co-ordinates are from the equator and the Greenwich meridian, respectively.

So, what I think you need to do, is to tell your library that the first item in your lat lon arrays (i.e. latlon[0] is longitude, and the second item (latlon[1]) is latitude. If the javascript library you are using cannot switch round those co-ordinates then I will eat my hat, and frankly, you shouldn't use it if this basic functionality isn't available. Whilst specs for things like geojson do exist of course, they are not universally followed by software implementations, so it helps to have some flexibility in how things are read in. If you mentioned the name of said library, someone who is familiar with it may even be able to tell you how.

So unless you are mapping in the middle of the Sahara desert or a remote part of the Congo the co-ordinate [ 0.07380334546815, 22.004177347957729 ] won't be much use to you :) (maybe you are, who's to know!)

  • Thanks for your response! The library I am using is called Highmaps. It's fairly new. I think the reason he suggested translating the longitude is the draw space most likely starts at 0,0 (bottom left corner of canvas) and then proceeds positively along the x,y axis. Negative values cause it to draw the polygons outside of the canvas (I assume). Maybe I am incorrect, but this is what I gathered from his response. – PStokes Jul 8 '14 at 19:29
  • 1
    No, what the library does is translate the lat/lon or projected co-ordinates to the draw space, so should handle co-ordinate systems transparently. I think you need to give an example of the data you are using because it must be a data or projection issue. – Stev_k Jul 8 '14 at 23:02

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.