Map Reprojection: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(not really convincing content: marked "Outdated content!")
(updated)
Line 1: Line 1:
{{OutDated}}
'''Question'''
'''Question'''


Line 7: Line 5:
'''Answer'''
'''Answer'''


# create an import location in the projection and datum of the map/image you want to import
For quality reasons, GRASS GIS handles '''one projection per location'''.
# import the map/image into the location
 
# create a destination location in the projection and datum you want to reproject the map/image into
'''Rationale''': Reprojection on the fly can easily introduce artifacts. Especially,
# working in the destination location, use r.proj or v.proj (depending on whether the map/image is raster or vector) to reproject the map/image from the import location to the destination location.
* vector maps: lines and polygons need to have a sufficiently high amount of vertices which is not guaranteed, hence {{cmd|v.split}} be used;
* raster maps:
** categorical maps need to be reprojected with nearest-neighbor method, while
** floating point data might be better reprojected with bilinear or cubic convolution methods)
Since many GIS users tend to blindly go ahead without selecting proper methods, the simple approach was adopted: put data which are in different projections into separate locations. That's it.
 
'''Reprojecting in GRASS GIS:'''
 
# create an import location in the projection and datum of the map/image you want to import,
# [[Importing data|import]] the map/image into the location,
# create a destination location in the projection and datum you want to reproject the map/image into,
# working in the destination location, use {{cmd|r.proj}} or {{cmd|v.proj}} (depending on whether the map/image is raster or vector) to reproject the map/image from the import location to the destination location.
 
Ready.
 
Another (similar) strategy frequently needed when maps need to be imported using, e.g. {{cmd|v.in.ogr}} or {{cmd|r.in.gdal}}, is to tell these programs to create a new location (argument "location"). If the imported data contains proper <code>PROJ_INFO</code> files, they can be reprojected into the current mapset, using the the projection in the current location/mapset.


If your raster data set is too big (i.e., 2GB or so when using an outdated GRASS GIS version), {{cmd|r.proj}} might crash. Instead, export as a GeoTIFF, use <code>gdalwarp</code> to change the project and then import the new GeoTIFF file. If you have installed <code>gdal</code>, you almost certainly have <code>gdalwarp</code> as well. Directions for <code>gdalwarp</code> are at http://www.gdal.org/gdalwarp.html. The options for <code>gdalwarp</code> are a bit confusing for newbies. In the following example of projecting a GeoTIFF based on SRTM elevation data to UTM 37N, <code>-t_srs</code> is the output file projection, <code>AfricaHornElev.tif</code> is the input file and <code>AfricaHornElev37n.tif</code> is the output file.
 
''GDAL alternative'': export as a GeoTIFF, use <code>gdalwarp</code> to change the projection and then import the new GeoTIFF file into GRASS GIS. If you have installed <code>gdal</code>, you almost certainly have <code>gdalwarp</code> as well. Indications for <code>gdalwarp</code> are found at http://www.gdal.org/gdalwarp.html. The options for <code>gdalwarp</code> may be a bit confusing for newbies. In the following example of projecting a GeoTIFF based on SRTM elevation data to UTM 37N, <code>-t_srs</code> is the output file projection, <code>AfricaHornElev.tif</code> is the input file and <code>AfricaHornElev37n.tif</code> is the output file.


<source lang="bash">
<source lang="bash">
Line 18: Line 32:
</source>
</source>


Another (similar) strategy frequently needed when maps need to be imported using, e.g. {{cmd|v.in.ogr}} or {{cmd|r.in.gdal}}, is to tell these programs to create a new location (argument "location"). If the imported data contains proper <code>PROJ_INFO</code> files, they can be reprojected into the current mapset, using the the projection in the current location/mapset.
== See also ==
 
* [[Location and Mapsets]]


[[Category:FAQ]]
[[Category:FAQ]]

Revision as of 17:18, 15 February 2014

Question

How to change map/image projections, datums, etc in GRASS GIS?

Answer

For quality reasons, GRASS GIS handles one projection per location.

Rationale: Reprojection on the fly can easily introduce artifacts. Especially,

  • vector maps: lines and polygons need to have a sufficiently high amount of vertices which is not guaranteed, hence v.split be used;
  • raster maps:
    • categorical maps need to be reprojected with nearest-neighbor method, while
    • floating point data might be better reprojected with bilinear or cubic convolution methods)

Since many GIS users tend to blindly go ahead without selecting proper methods, the simple approach was adopted: put data which are in different projections into separate locations. That's it.

Reprojecting in GRASS GIS:

  1. create an import location in the projection and datum of the map/image you want to import,
  2. import the map/image into the location,
  3. create a destination location in the projection and datum you want to reproject the map/image into,
  4. working in the destination location, use r.proj or v.proj (depending on whether the map/image is raster or vector) to reproject the map/image from the import location to the destination location.

Ready.

Another (similar) strategy frequently needed when maps need to be imported using, e.g. v.in.ogr or r.in.gdal, is to tell these programs to create a new location (argument "location"). If the imported data contains proper PROJ_INFO files, they can be reprojected into the current mapset, using the the projection in the current location/mapset.


GDAL alternative: export as a GeoTIFF, use gdalwarp to change the projection and then import the new GeoTIFF file into GRASS GIS. If you have installed gdal, you almost certainly have gdalwarp as well. Indications for gdalwarp are found at http://www.gdal.org/gdalwarp.html. The options for gdalwarp may be a bit confusing for newbies. In the following example of projecting a GeoTIFF based on SRTM elevation data to UTM 37N, -t_srs is the output file projection, AfricaHornElev.tif is the input file and AfricaHornElev37n.tif is the output file.

gdalwarp -t_srs '+proj=utm +zone=37 +ellps=WGS84 +datum=WGS84 +units=m +no_defs' -r bilinear AfricaHornElev.tif AfricaHornElev37n.tif

See also