Adding coordinate system information to spatial data
Sometimes data is delivered without coordinate system description at file level. All datasets in PaITuli have coordinate system description in metadata, but not all at file level. To shape files the coordinate system description .prj files were added in June 2014. Usually it is possible to display data in unknown coordinate system in GIS software, but it is not possible to show it together with data in some other coordinate system. The methods below only add the coordinate system information, they do not transform data to this coordinate system.
Before you start, make sure you have a back-up copy of your data. Most of these methods overwrite existing files.
Adding coordinate system information to a single file
Most GIS desktop software have a way, for defining coordinate system for data.
- In ArcGIS
- In QGIS it is for vectord data: Define current Projection under Vector -> Data Management Tools and for raster data Assign Projection under Raster -> Projections. But be careful QGIS uses GDAL/OGR tools in background (ogr2ogr and gdalwarp), so see the comments below.
- GDAL/OGR have also command line tools for these purporses. You should define the coordinate system using a_srs. Use ogr2ogr for vector data or gdal_edit for raster data. If gdal_edit can not update the original file use gdal_translate for raster data. Ogr2ogr and gdal_translate/gdalwarp create a copy of the original file and some settings may be changed from the original, for example compression or tiling of raster files.
ogr2ogr -a_srs EPSG:2394 output_nocs.shp input_kkj4.shpgdal_edit -a_srs EPSG:3067 input.tif
gdal_translate -a_srs EPSG:2394 input_nocs.tif output_kkj4.tif
- In MapInfo there seems to be no special tool. You have to save a copy and define the projection during that.
Adding coordinate system information to several files
If you have several files missing coordinate system, then you can use batch processing tools.
- ArcGIS batch processing, with example of defining coordinate system. The big problem here is, that each input file has to be added separately.
- QGIS Assign Projection tool in batch mode (only rasters). Here it is possible to select a folder (and its subfolders) with input files.
Adding coordinate system information to a lof of files
If you have a lot of files (>20), then it makes sense to use command-line tools or batch files.
- GDAL/OGR, see for loops at the end of page.
- ArcPy scripts
Adding coordinate system information to shape files
Shape files are a kind of special case. Because the coordinate system information for a shape file is in a separate .prj file, it is possible to add coordinate system information to shape files also with just adding a .prj file next to the .shp file. The .prj file must have exactly the same name as .shp file. So if you have rivers.shp, you should add rivers.prj file. The advantage of this system is, that you do not modify the original file in any way, so minimizing risk of something going wrong.
The content of a .prj file for the same coordinate system is always the same. To get seed .prj file copy it from some existing dataset that has the same coordinate system or define coordinate system for a single file and copy then the .prj file.
For loop for adding .prj files to all .shp files.
FOR /R %i IN (*.shp) DO copy ykj.prj %~pni.prj
Adding coordinate system information to PNG files
Similarly to Shape files, also to PNG files coordinate system info may be added with adding an extra file - [filename].png.aux.xml. The content of aux.xml files for the files with same coordinate system is the same. (aux.xml files may contain also other file-specific information like color maps or raster statistics, so if you already have a aux.xml file, you should not use this method.) To get the example aux.xml file, use some tool mentioned above. And then make a copy of the aux.xml file to all mapsheets.
FOR /R %i IN (*.png) DO copy ykj.png.aux.xml %~pni.png.aux.xml