Converting latitude and longitude to point in geodjango?

I am doing the geodjango tutorial and I went on google and chose a random longitude and latitude in Kansas, I am using srid=4326 for my polygons

So I got this random lat and long on google maps in Kansas USA

``````lat, long = 38.670049, -99.565798
``````

Now I am trying to see where in the world it is

``````>>> from django.contrib.gis.geos import Point
>>> pnt = Point(38.670049, -99.565798)
>>> WorldBorder.objects.get(mpoly__intersects=pnt)
...
...
world.models.DoesNotExist: WorldBorder matching query does not exist.
``````

Using the tutorial point I get

``````>>> pnt = Point(-95.3385, 29.7245)
>>> WorldBorder.objects.get(mpoly__intersects=pnt)
<WorldBorder: United States>
``````

So my database is imported and working.

So clearly Points are not the same as latitude and longitude, how do I convert between the two

It seems google maps has the lat/long the other way around, see coordinates in image below at the bottom from google maps:

``````# Try enter the coords in the same order as in image above
# Get wrong intersection
>>> from django.contrib.gis.geos import Point
>>> from world.models import WorldBorder
>>> pnt = Point(38.907636 , -77.036905)
>>> WorldBorder.objects.get(mpoly__intersects=pnt)
<WorldBorder: Antarctica>

# Swap them around, and it works
>>> pnt = Point(-77.036905, 38.907636)
>>> WorldBorder.objects.get(mpoly__intersects=pnt)
<WorldBorder: United States>
``````

Can anyone explain what is going on exactly. For a Point(x,y) which is the longitude and which is the latitude, is it

`Point(x,y)`

`x=longitude`

`y=latitude`

And in which order does Google maps present them in the picture above

I am not a GIS specialist or even novice.

• Not many features will contain a point at 99 degrees south. It helps if you always think in terms of X,Y order, and even write it "longitude and latitude". Commented May 15, 2016 at 19:56
• but i'm doing an intersection, surely any point within the USA will intersect with the USA polygon. so are points longitude and latitude? or are they some abitrary x,y coordinate system in geodjango Commented May 16, 2016 at 6:16
• What Vince is saying is that -99 latitude does not exist. The South Pole is -90. You have reversed the coordinates in your two examples. Commented May 16, 2016 at 9:10
• Please see updated question Commented May 16, 2016 at 14:57

Straight from the documentation:

Another option is to use the constructor for the specific geometry type that you wish to create. For example, a Point object may be created by passing in the X and Y coordinates into its constructor:

``````> >>> from django.contrib.gis.geos import Point
> >>> pnt = Point(5, 23)
``````

Note "X and Y coordinates". X is longitude, Y is latitude. In this example 5 is longitude and 23 is latitude.

• so, if you're coming from google maps, and experienced to latlng objects and the like, x and y are like switched. this caused my some headache! Commented Dec 15, 2018 at 9:40
• This is incorrect! X - latitude, and Y - longitude! Commented Jul 4, 2023 at 14:18
• Longitude relates to the horizontal axis, as in west - east. Latitude relates to the vertical axis, as in north - south. We often hear "latitude - longitude", in this order. In that sense, you can say x and y are like switched but it's always better to understand their precise meaning. Commented Sep 27, 2023 at 23:32