Projecting a Point
In the previous chapter, we worked with the Eiffel Tower location. Again, we provided you the coordinates in a projected coordinate system, so you could, for example, calculate distances. Let's return to this iconic landmark, and express its location in geographical coordinates: 48°51′29.6″N, 2°17′40.2″E. Or, in decimals: latitude of 48.8584 and longitude of 2.2945.
Shapely geometry objects have no notion of a CRS, and thus cannot be directly converted to another CRS. Therefore, we are going to use the GeoPandas to transform the Eiffel Tower point location to an alternative CRS. We will put the single point in a GeoSeries, use the to_crs()
method, and extract the point again.
GeoPandas is already imported.
This exercise is part of the course
Working with Geospatial Data in Python
Exercise instructions
- Create a shapely point object with the coordinates of the Eiffel Tower and assign it to a variable called
eiffel_tower
. - Create a GeoSeries (called
s_eiffel_tower
) with the Eiffel Tower as the single element and specify the CRS to be EPSG:4326. - Convert
s_eiffel_tower
to EPSG:2154, and call the results_eiffel_tower_projected
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Construct a Point object for the Eiffel Tower
from shapely.geometry import Point
eiffel_tower = ____
# Put the point in a GeoSeries with the correct CRS
s_eiffel_tower = geopandas.GeoSeries([____], crs={'init': '____'})
# Convert to other CRS
s_eiffel_tower_projected = s_eiffel_tower.____
# Print the projected point
print(s_eiffel_tower_projected)