Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to assign this EPSG projection to my newly created shapefiles using ogr.
The OGR Projections Tutorial says:

...any geographic coordinate system in the EPSG database can be set by it's GCS code number if the EPSG database is available

But this doesn't work for me:

spatialReference = ogr.osr.SpatialReference()
spatialReference.SetWellKnownGeogCS("Amersfoort / RD New") 

returns 6 at the prompt.

Doesn't work either (also returns 6 at the prompt by the way):


This does work (returns 0 at the prompt):


If I define the proj4-string manually it works too (also returns 0).

proj4_str = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889..."

Conclusion: Not all codes from the EPSG database are available. The spatialReference.XXX() -methods return a code for setting the projection successfully or not(?). Has somebody more experience concerning these techniques and can explain what is going on?

share|improve this question

From the docs:

The following well known text values are currently supported:

  • "WGS84": same as "EPSG:4326" but has no dependence on EPSG data files.
  • "WGS72": same as "EPSG:4322" but has no dependence on EPSG data files.
  • "NAD27": same as "EPSG:4267" but has no dependence on EPSG data files.
  • "NAD83": same as "EPSG:4269" but has no dependence on EPSG data files.
  • "EPSG:n": same as doing an ImportFromEPSG(n).

That explains why

spatialReference.SetWellKnownGeogCS("Amersfoort / RD New")

doesn't work. The code below


works for my machine while


doesn't. Can you test it on your machine?

doesn't work,I think it's still not in the EPSG database that comes with GDAL. ( Got no results while grepping for 28992 in csv files that contain the EPSG codes ) I still don't know.

share|improve this answer
"EPSG:n": same as doing an ImportFromEPSG(n)." should do the trick for n = 28992, right? Or what am I missing? Which csv file do you mean? I couldn't find a list with the EPSG codes. – LarsVegas Sep 24 '12 at 14:52
Odd. spatialReference.ImportFromEPSG(28992) works for me while spatialReference.SetWellKnownGeogCS("Amersfoort / RD New") doesn't. What is your OS btw? I'm on Windows and I found them on C:\OSGeo4W\share\gdal – R.K. Sep 24 '12 at 14:56
I'm on windows, too. Just checked if I could find the csv and the COORD_REF is 28992. So it should work after all. – LarsVegas Sep 24 '12 at 15:01
Just tested it again. Still doesn't work. What is the csv file called on your machine? – LarsVegas Sep 24 '12 at 15:07
It's a whole directory. Lots of csv files. Which one doesn't work? EPSG:7415? Have you tried spatialReference.ImportFromEPSG(28992)? That one works, at least. – R.K. Sep 24 '12 at 15:10

EPSG:28992 is projected system, not geographical so you cannot call SetWellKnownGeogCS() for it. You need to define both ellipsoid (GeogCS) and projection method (ProjCS) for projected systems. For UTM projection you can set both explicitly:

proj = osr.SpatialReference()
proj.SetProjCS("UTM 30N (WGS84)")
proj.SetUTM(30, True)

where SetProjCS() only sets name, not the parameters. For non-UTM projections calling


sets both for you (ellipsoid and projection).

share|improve this answer
The GCS used for Amersfoort RD New is EPSG:4289 Amersfoort. Can you try if that wroks? – AndreJ May 13 at 12:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.