1

I want to convert geospatial data stored in a .csv file into GeoJSON or ESRI Shapefiles. The problem is that the coordinate reference system is not in the database of EPSG codes. The originator however provides a .prj file with the relevant information.

// ETRS89_UTM_Zone_33_BB_6stellig.prj
PROJCS["ETRS89_UTM_Zone33_6",
  GEOGCS["GCS_ETRS_1989",
    DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],
    PRIMEM["Greenwich",0.0],
    UNIT["Degree",0.0174532925199433]
  ],
  PROJECTION["Transverse_Mercator"],
  PARAMETER["False_Easting",500000.0],
  PARAMETER["False_Northing",0.0],
  PARAMETER["Central_Meridian",15.0],
  PARAMETER["Scale_Factor",0.9996],
  PARAMETER["Latitude_Of_Origin",0.0],
  UNIT["Meter",1.0]
]

Source: Landesvermessung und Geobasisinformationen Brandenburg

  • Is at least the geodetic datum matching on any one you can find on spatialreference.org ? If you have to do a geodetic datum transformation, you will need transformation parameters, which you normally can't get by yourself except you are an mathematics and/or geodetic genius. Perhaps you can post the content of the prj file here – Jürgen Zornig May 21 '14 at 20:03
2

If you want to use ogr2ogr and have a valid .prj file, you don't need a matching EPSG Code.

CSV itself does not have CRS information, so you have to apply the definition with ogr2ogr.

Your input file points.csv should look like this

id,x,y
0,455795.63291,5767308.43056
1,448404.098752,5790679.95123
2,437594.358317,5777140.87242

You need a vrt file points.vrt to tell ogr2ogr which columns contain the geometry information:

<OGRVRTDataSource>
    <OGRVRTLayer name="points">
        <SrcDataSource>points.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
        <GeometryField encoding="PointFromColumns" x="X" y="Y"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

The command should be:

ogr2ogr -a_srs ETRS89_UTM_Zone33_6stellig.prj points.shp points.vrt

This will definitely work for shapefiles. For Geojson, the CRS must be linked as described in http://geojson.org/geojson-spec.html#linked-crs

Alternatively, you can use this vrt:

<OGRVRTDataSource>
    <OGRVRTLayer name="points">
        <SrcDataSource>points.csv</SrcDataSource>
        <GeometryType>wkbPoint</GeometryType>
      <LayerSRS>ETRS89_UTM_Zone33_6stellig.prj </LayerSRS>
        <GeometryField encoding="PointFromColumns" x="X" y="Y"/>
    </OGRVRTLayer>
</OGRVRTDataSource>

and a commandline without a_srs:

ogr2ogr points.shp points.vrt

But to be honest, I see no differences in parameters to the standard EPSG:25833:

PROJCS["ETRS89_UTM_zone_33N",
  GEOGCS["GCS_ETRS_1989",
    DATUM["D_ETRS_1989",
    SPHEROID["GRS_1980",6378137,298.257222101]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]],
  PROJECTION["Transverse_Mercator"],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",15],
    PARAMETER["scale_factor",0.9996],
    PARAMETER["false_easting",500000],
    PARAMETER["false_northing",0],
    UNIT["Meter",1]]
  • It generates a .dbf file only. Can you tell what the ogr2ogr driver expects as the correct column names for longitude and latitude values? I wonder if I can combine the .prj (custom EPSG-code) with a .vrt definition? – JJD May 22 '14 at 10:01
  • See my extended answer. I usually do this in QGIS, adding a delimited text file, then saving as a shapefile. You get an overview of the points as well. – AndreJ May 22 '14 at 11:18
  • Thank you. It finally worked with ETRS89_UTM_Zone33_7stellig.prj. My .vrt file contained <LayerSRS>WGS84</LayerSRS> which is a problem when I specify the SRS via the .prj file, I guess. – JJD May 22 '14 at 12:18
  • 1
    Yes, that's why I left out that line. But <LayerSRS>ETRS89.prj</LayerSRS> would work too. – AndreJ May 22 '14 at 12:23
  • You mean <LayerSRS>ETRS89_UTM_Zone33_6stellig.prj</LayerSRS> for the example? – JJD May 22 '14 at 12:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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