How to Identify Coordinate System (CRS) from projection file using Python
up vote
2
down vote
favorite
I am working on many shapefiles (their corresponding projection files are also presented).
Every shapefile has a different Coordinate System, so it becomes difficult to plot these in a generic manner.
How can I identify with Python what is the CRS used in the shapefile?
For example, the ".prj"
file for some shapefiles is given below, but I am not able to identify what is the CRS to be used.
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
python coordinate-system shapefile
add a comment |
up vote
2
down vote
favorite
I am working on many shapefiles (their corresponding projection files are also presented).
Every shapefile has a different Coordinate System, so it becomes difficult to plot these in a generic manner.
How can I identify with Python what is the CRS used in the shapefile?
For example, the ".prj"
file for some shapefiles is given below, but I am not able to identify what is the CRS to be used.
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
python coordinate-system shapefile
1
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am working on many shapefiles (their corresponding projection files are also presented).
Every shapefile has a different Coordinate System, so it becomes difficult to plot these in a generic manner.
How can I identify with Python what is the CRS used in the shapefile?
For example, the ".prj"
file for some shapefiles is given below, but I am not able to identify what is the CRS to be used.
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
python coordinate-system shapefile
I am working on many shapefiles (their corresponding projection files are also presented).
Every shapefile has a different Coordinate System, so it becomes difficult to plot these in a generic manner.
How can I identify with Python what is the CRS used in the shapefile?
For example, the ".prj"
file for some shapefiles is given below, but I am not able to identify what is the CRS to be used.
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]]
python coordinate-system shapefile
python coordinate-system shapefile
edited Nov 27 at 11:58
Taras
1,5902522
1,5902522
asked Nov 27 at 11:13
userxxx
1133
1133
1
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34
add a comment |
1
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34
1
1
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34
add a comment |
3 Answers
3
active
oldest
votes
up vote
3
down vote
For example with fiona:
c = fiona.open('docs/data/test_uk.shp')
crs = c.crs
find it in the docs page 28
If you need the EPSG code there is good inspiration to take here using pyproj
add a comment |
up vote
1
down vote
Is it not just that simple as below (I know he wanted to know from prj file but I think this is more simple)?
import arcpy
arcpy.env.workspace = r"PATH TO FOLDER OR GDB"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
print(spatialRef.Name)
https://www.e-education.psu.edu/geog485/node/115
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
add a comment |
up vote
1
down vote
A number of Python modules exist to work with CRS or projection files
Pypi:ESPSG or Pypi:CRS
- GitHub: EPSG
For example, you can use epsg-ident or sridentify (Quickly get the EPSG code from a .prj file or WKT)
from sridentify import Sridentify
ident = Sridentify()
# from file
ident.from_file('schisto.prj')
ident.get_epsg()
31370
# from WKT
ident = Sridentify(prj="""GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]])
ident.get_epsg()
4326
But it doesn't always work
ident = Sridentify(prj = """GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]""")
ident.get_epsg()
# nothing
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
For example with fiona:
c = fiona.open('docs/data/test_uk.shp')
crs = c.crs
find it in the docs page 28
If you need the EPSG code there is good inspiration to take here using pyproj
add a comment |
up vote
3
down vote
For example with fiona:
c = fiona.open('docs/data/test_uk.shp')
crs = c.crs
find it in the docs page 28
If you need the EPSG code there is good inspiration to take here using pyproj
add a comment |
up vote
3
down vote
up vote
3
down vote
For example with fiona:
c = fiona.open('docs/data/test_uk.shp')
crs = c.crs
find it in the docs page 28
If you need the EPSG code there is good inspiration to take here using pyproj
For example with fiona:
c = fiona.open('docs/data/test_uk.shp')
crs = c.crs
find it in the docs page 28
If you need the EPSG code there is good inspiration to take here using pyproj
edited Nov 27 at 11:52
answered Nov 27 at 11:44
YoLecomte
1,870218
1,870218
add a comment |
add a comment |
up vote
1
down vote
Is it not just that simple as below (I know he wanted to know from prj file but I think this is more simple)?
import arcpy
arcpy.env.workspace = r"PATH TO FOLDER OR GDB"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
print(spatialRef.Name)
https://www.e-education.psu.edu/geog485/node/115
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
add a comment |
up vote
1
down vote
Is it not just that simple as below (I know he wanted to know from prj file but I think this is more simple)?
import arcpy
arcpy.env.workspace = r"PATH TO FOLDER OR GDB"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
print(spatialRef.Name)
https://www.e-education.psu.edu/geog485/node/115
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
add a comment |
up vote
1
down vote
up vote
1
down vote
Is it not just that simple as below (I know he wanted to know from prj file but I think this is more simple)?
import arcpy
arcpy.env.workspace = r"PATH TO FOLDER OR GDB"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
print(spatialRef.Name)
https://www.e-education.psu.edu/geog485/node/115
Is it not just that simple as below (I know he wanted to know from prj file but I think this is more simple)?
import arcpy
arcpy.env.workspace = r"PATH TO FOLDER OR GDB"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
desc = arcpy.Describe(fc)
spatialRef = desc.spatialReference
print(spatialRef.Name)
https://www.e-education.psu.edu/geog485/node/115
answered Nov 27 at 11:28
JuniorPythonNewbie
1949
1949
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
add a comment |
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
Thanks for this, but is there any alternate solution which does not use arcpy.
– userxxx
Nov 27 at 11:37
add a comment |
up vote
1
down vote
A number of Python modules exist to work with CRS or projection files
Pypi:ESPSG or Pypi:CRS
- GitHub: EPSG
For example, you can use epsg-ident or sridentify (Quickly get the EPSG code from a .prj file or WKT)
from sridentify import Sridentify
ident = Sridentify()
# from file
ident.from_file('schisto.prj')
ident.get_epsg()
31370
# from WKT
ident = Sridentify(prj="""GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]])
ident.get_epsg()
4326
But it doesn't always work
ident = Sridentify(prj = """GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]""")
ident.get_epsg()
# nothing
add a comment |
up vote
1
down vote
A number of Python modules exist to work with CRS or projection files
Pypi:ESPSG or Pypi:CRS
- GitHub: EPSG
For example, you can use epsg-ident or sridentify (Quickly get the EPSG code from a .prj file or WKT)
from sridentify import Sridentify
ident = Sridentify()
# from file
ident.from_file('schisto.prj')
ident.get_epsg()
31370
# from WKT
ident = Sridentify(prj="""GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]])
ident.get_epsg()
4326
But it doesn't always work
ident = Sridentify(prj = """GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]""")
ident.get_epsg()
# nothing
add a comment |
up vote
1
down vote
up vote
1
down vote
A number of Python modules exist to work with CRS or projection files
Pypi:ESPSG or Pypi:CRS
- GitHub: EPSG
For example, you can use epsg-ident or sridentify (Quickly get the EPSG code from a .prj file or WKT)
from sridentify import Sridentify
ident = Sridentify()
# from file
ident.from_file('schisto.prj')
ident.get_epsg()
31370
# from WKT
ident = Sridentify(prj="""GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]])
ident.get_epsg()
4326
But it doesn't always work
ident = Sridentify(prj = """GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]""")
ident.get_epsg()
# nothing
A number of Python modules exist to work with CRS or projection files
Pypi:ESPSG or Pypi:CRS
- GitHub: EPSG
For example, you can use epsg-ident or sridentify (Quickly get the EPSG code from a .prj file or WKT)
from sridentify import Sridentify
ident = Sridentify()
# from file
ident.from_file('schisto.prj')
ident.get_epsg()
31370
# from WKT
ident = Sridentify(prj="""GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]])
ident.get_epsg()
4326
But it doesn't always work
ident = Sridentify(prj = """GEOGCS["WGS84(DD)", DATUM["WGS84", SPHEROID["WGS84", 6378137.0, 298.257223563]], PRIMEM["Greenwich", 0.0], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH]""")
ident.get_epsg()
# nothing
answered Nov 27 at 17:10
gene
36.3k149108
36.3k149108
add a comment |
add a comment |
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f304061%2fhow-to-identify-coordinate-system-crs-from-projection-file-using-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Which python library or tools do you use to read your shapefile?
– YoLecomte
Nov 27 at 11:21
I have tried GeoPandas, Shapely, and Fionna
– userxxx
Nov 27 at 11:34