# Extract the north-west point of a shapely rectangle

I am using Python in a Jupyter notebook.

I'have created a geometry with `shapely` and I need to extract the coordinate of the north-west corner of it.

``````from shapely.geometry import Polygon

lng = -180
lat=-90
lon_point_list = [lng, lng+10, lng+10, lng]
lat_point_list = [lat, lat, lat+10, lat+10]

polygon_geom = Polygon(zip(lon_point_list, lat_point_list))
``````

of course this shape is an example but my shape is always a rectangle

Is there a trick to perform it ? (I can use another library such as `geopandas`)

• Does your geometry is always a rectangle? What do you define as "north-west point of a polygon". Similar question here gis.stackexchange.com/questions/296916/… (this comment is because it's unclear to me what you expect) – ThomasG77 Jul 15 '20 at 17:32
• effectively it's always a rectangle ;-) – Pierrick Rambaud Jul 15 '20 at 17:53

The following approach uses geopandas `bounds` to extract the `minx, miny, maxx, maxy` value of the rectangle bounds. From there, simply extract the minx and maxy values to produce the northwest corner coordinate. Note that this approach assumes the rectangle is not rotated.

``````from shapely.geometry import Polygon
import geopandas as gpd

lng = -180
lat=-90
lon_point_list = [lng, lng+10, lng+10, lng]
lat_point_list = [lat, lat, lat+10, lat+10]

polygon_geom = Polygon(zip(lon_point_list, lat_point_list))

# Returns a tuple with minx, miny, maxx, maxy of bounding box
b = polygon_geom.bounds

# Find the NW corner of bounds (minx, maxy)
nw_corner = (b[0], b[3])
print(nw_corner)
``````
• To be less general, my use case is to retrieve tiles from a dataset (world have been cut in small pieces of 10x10°) so not a single is rotated. This solution is perfect for me ! – Pierrick Rambaud Jul 16 '20 at 5:20