Tuesday, 1 May 2018

python - ogr: how to use epsg database for RD New projection?


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?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...