Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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):

spatialReference.ImportFromEPSG(28992)

This does work (returns 0 at the prompt):

spatialReference.SetWellKnownGeogCS("WGS84")

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..."
spatialReference.ImportFromProj4(proj4_str)

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
add comment

1 Answer

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

spatialReference.ImportFromEPSG(28992)

works for my machine while

spatialReference.SetWellKnownGeogCS("EPSG:28992")

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
show 4 more comments

Your Answer

 
discard

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.