I'm trying to load a bunch of latitude/longitude pairs into a PostGIS geography type so as to be able to query by location.
In particular I have a table with float latitude and longitude columns and a geography(Point, 4326)
column. I would like to do
update mytable set geography = ???
The documentation appears to suggest that the following should work:
update mytable set geography = ST_GeogFromText('POINT(' || latitude || ' ' || longitude || ')');
It doesn't. I don't know what it's interpreting this point as meaning, but it only allows the longitude to lie between -90 and 90, so it's clearly not a longitude.
So, what do I do?
World Map ConversionDivide the length of the x-axis by 180 and the y-axis by 90. This will give you the equivalent of each latitude (LA) and longitude (LO) angle in inches. Mark the coordinates of a location on the two axes.
Similar to latitude, the corresponding measurement of distance around the Earth is called longitude. The imaginary lines of latitude and longitude intersect each other, forming a grid that covers Earth. The points of latitude and longitude are called coordinates, and can be used together to locate any point on Earth.
geography is a spatial data type used to represent a feature in geodetic coordinate systems. Geodetic coordinate systems model the earth using an ellipsoid. Spatial operations on the geography type provide more accurate results by taking the ellipsoidal model into account.
...sigh. Stupidity on my part. Apparently the correct order is longitude, latitude. I was fooled into thinking that both coordinates had the same range (-180 to 180) so thought something more subtle was going on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With