python – How to Read Shapely File in Specific Coordinate Format or Change Packed DMS with Decimal to DMS Format

coordinate systemgeopandaspythonshapefileshapely

I am using GeoPandas to read a shapefile using read_file() function. However, my polygons are in the following format:

(longitude: latitude) = (3229083.936279297 13792922.909729).

Also, whenever I visualize I found that the latitude part, e.g. 13792922.909729 actually means 1.37, so there are some fractional values hidden inside the polygon I guess.

I am not very familiar with this format. Is it possible to convert automatically these polygons into normal DMS format, e.g. like (longitude: latitude) = (-95.606088 29.761605) during reading time or normal format into that format. Can give me some insights into the format?

Best Answer

Uncertain that the 1.37 is correct? The shapefile being read will have a coordinate reference system (CRS) in it's .prj file, that determines how shapely/geopandas understands the coordinates. To translate the coords into the more commonly understood WGS 1984 format you can use the .to_crs("epsg:4326") command.

Longitude is always before latitude on Cartesian plane.

gf = gp.read_file("path_to_file")
print(gf.crs)

gf = gf.to_crs("epsg:4326")
print(gf.crs)

gf.plot()