Tips for Arc users: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(add arcgis category)
(→‎Working with your ArcGIS data: remove r.in.arc, improve wording and sectioning)
Line 5: Line 5:
== Working with your ArcGIS data ==
== Working with your ArcGIS data ==


'''Importing ArcGIS Data'''
=== Importing ArcGIS Data ===


Grass provides convertors for importing ESRI shapefiles, e00 files, and many other GIS formats as well. The key Grass programs for importing vector formats are {{cmd|v.in.ogr}} (for ESRI shapefiles, MapInfo files, SDTS, TIGER, etc.) and {{cmd|v.in.e00}} for e00 format.
GRASS GIS provides converters for importing ESRI shapefiles, e00 files, and many other GIS formats as well. The key GRASS modules for importing vector formats are {{cmd|v.in.ogr}} (for ESRI Shapefiles, MapInfo files, SDTS, TIGER, etc.) and {{cmd|v.in.e00}} for e00 format. For raster data, there is {{cmd|r.in.gdal}}.


'''Coordinate Reference Systems'''
=== Coordinate Reference Systems ===


The GRASS data structure requires that each data layer have its CRS exactly defined. This is done by maintaining data layers within a "[[Location and Mapsets|Location]]". Each Location has a strictly defined projection, and datum, and all the data layers (raster and vector) within that location should already be either created in or projected to that CRS. GRASS does '''not''' do "on-the-fly" reprojection due to the problems often encountered in other GIS software with datum mismatches. So data layers in one location are not visible from other locations. However GRASS does supply a collection of [[Common_Tasks#GIS_Tasks|tools]] for projecting vector and raster layers from one location to another. Use of these tools is explained in the {{cmd|projectionintro}} manual.
The GRASS data structure requires that each data layer have its CRS exactly defined. This is done by maintaining data layers within a "[[Location and Mapsets|Location]]". Each Location has a strictly defined projection, and datum, and all the data layers (raster and vector) within that location should already be either created in or projected to that CRS. GRASS does '''not''' do "on-the-fly" reprojection to avoid often encountered in other GIS software with datum mismatches. Consequently, data layers in one location are not visible from other locations. However, GRASS does supply a collection of [[Common_Tasks#GIS_Tasks|tools]] for projecting vector and raster layers from one location to another. Use of these tools is explained in the {{cmd|projectionintro|manual}}.
   
   
=== Vector import/export commands ===
=== Vector import/export commands ===
Line 22: Line 22:




==== Import of Shapefiles into Grass ====
==== Import of Shapefiles into GRASS ====


specify the directory
specify the directory
Line 57: Line 57:


=== Raster import/export commands ===
=== Raster import/export commands ===
* {{cmd|r.in.arc}} - Convert an ESRI ARC/INFO ascii raster file (GRID) into a GRASS (binary) raster map layer.
* {{cmd|r.out.arc}} - Converts a GRASS raster map layer into an ESRI ARCGRID file.
** [http://listserver.mbari.org/sympa/arc/mbsystem/2009-03/msg00031.html Some tips and tricks for imporing Arc ASCII grids from external software]


* {{cmd|r.in.gdal}} - Import [http://www.gdal.org GDAL] supported raster file into a binary raster map layer.
* {{cmd|r.in.gdal}} - Import [http://www.gdal.org GDAL] supported raster file into a binary raster map layer.
Line 76: Line 71:


The trick is to convert the raster coverage to vector
The trick is to convert the raster coverage to vector
areas to take advantage of GRASS's rich vector attribute/database tie-ins. You can use either {{cmd|r.in.arc}} or {{cmd|r.in.gdal}} for the import.
areas to take advantage of GRASS's rich vector attribute/database tie-ins. You can use {{cmd|r.in.gdal}} for the import.
If using r.in.arc be careful to set the map type to CELL for categorical maps.


  # import ArcASCII grid to UTM55S location
  # import ArcASCII grid to UTM55S location
Line 98: Line 92:
  v.db.connect map=aas_z55 driver=dbf table=aas_z55 key=value
  v.db.connect map=aas_z55 driver=dbf table=aas_z55 key=value


done!
Done. The data are in GRASS GIS database.


==== Import E00 raster grids ====
==== Import E00 raster grids ====


The {{cmd|v.in.e00}} module only handles vector data. You will have to convert raster E00 data into an Arc ASCII grid before importing into GRASS with {{cmd|r.in.arc}} or {{cmd|r.in.gdal}}.
* The {{cmd|v.in.e00}} module only handles vector data. You will have to convert raster E00 data into an Arc ASCII grid before importing into GRASS with {{cmd|r.in.gdal}}.
 
* [http://lists.osgeo.org/pipermail/grass-user/2009-October/052758.html See instructions in this mailing list post] about the "ArcExplorer Import Utility"
* [http://lists.osgeo.org/pipermail/grass-user/2009-October/052758.html See instructions in this mailing list post] about the  
"ArcExplorer Import Utility"


=== Various hydrology and terrain analysis commands ===
=== Various hydrology and terrain analysis commands ===

Revision as of 01:59, 1 February 2016

Basic tutorial for GRASS GIS

See GRASS GIS tutorial - at Geostat 2012

Working with your ArcGIS data

Importing ArcGIS Data

GRASS GIS provides converters for importing ESRI shapefiles, e00 files, and many other GIS formats as well. The key GRASS modules for importing vector formats are v.in.ogr (for ESRI Shapefiles, MapInfo files, SDTS, TIGER, etc.) and v.in.e00 for e00 format. For raster data, there is r.in.gdal.

Coordinate Reference Systems

The GRASS data structure requires that each data layer have its CRS exactly defined. This is done by maintaining data layers within a "Location". Each Location has a strictly defined projection, and datum, and all the data layers (raster and vector) within that location should already be either created in or projected to that CRS. GRASS does not do "on-the-fly" reprojection to avoid often encountered in other GIS software with datum mismatches. Consequently, data layers in one location are not visible from other locations. However, GRASS does supply a collection of tools for projecting vector and raster layers from one location to another. Use of these tools is explained in the projectionintro.

Vector import/export commands

  • v.in.ogr - Convert OGR supported vector formats to GRASS vector format.
  • v.out.ogr - Convert from the GRASS vector format to one of the supported OGR vector formats.
  • v.in.e00 - Import a E00 coverage into a GRASS vector map.


Import of Shapefiles into GRASS

specify the directory

v.in.ogr dsn=/home/data/navigation_files output=Tracklines layer=Ship_Tracklines
or just the .shp file name directly
v.in.ogr dsn=Ship_Tracklines.shp output=Tracklines

This is the syntax for v.in.ogr in its most basic form. The dsn parameter corresponds to the directory path of the vector you are trying to import. You can enter a full or relative path. The output paramter, aptly enough, is the name of your output Grass vector. The layer parameter is the name of the input vector, be it shapefile, MapInfo file, or what have you.

Export of Shapefiles from GRASS

Shapefiles can only hold one type of data (point, line, polygon) per shapefile. You can't export a GRASS vector map with both points and areas to a single shapefile. You'll have to do it in two passes to two different files with v.out.ogr and different "type=" parameters.

Export lines from GRASS vector map to Shapefile format (generates /tmp/testogr.shp and related files):

v.out.ogr input=multi type=line dsn=/tmp olayer=testogr 

Export areas from GRASS vector map to Shapefile format (generates /tmp/testogr.shp and related files):

v.out.ogr input=multi type=area dsn=/tmp olayer=testogr 

Export 3D lines from GRASS vector map to Shapefile format:

v.out.ogr input=lines_3d type=line dsn=/tmp olayer=testogr lco="SHPT=ARCZ"

Various vector commands

  • Editing differences
Tips for Digitizing area features with attributes

Raster import/export commands

  • r.in.gdal - Import GDAL supported raster file into a binary raster map layer.
    • Import a binary ArcInfo raster grid into GRASS:
      • See the GDAL help page for AIC
      • Often the biggest .adf file is the right one to import -- check your data values after importing even if they visually look correct!
r.in.gdal input=/path/to/map/hdr.adf output=map
  • r.out.gdal - Exports GRASS raster data into various formats.
    • Export a raster as a GeoTIFF for use with ArcView 3.1:
r.out.gdal input=map output=map.tif type=Byte createopt="INTERLEAVE=PIXEL,COMPRESS=PACKBITS"

Import ArcASCII raster grid and connect to database

The trick is to convert the raster coverage to vector areas to take advantage of GRASS's rich vector attribute/database tie-ins. You can use r.in.gdal for the import.

# import ArcASCII grid to UTM55S location
r.in.gdal  input=aas_z55.asc output=aas_z55
r.colors aas_z55.gdal color=random
r.info aas_z55

# convert to vector areas, using raster value for category
g.region rast=aas_z55
r.to.vect -v in=aas_z55.gdal out=aas_z55 feature=area

# get rid of empty DBF table created by r.to.vect
v.db.droptable aas_z55

# copy real DBF file into $MAPSET/dbf/ directory
eval `g.gisenv`
cp /tmp/au/aas_z55.DBF "$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/aas_z55.dbf"

# connect full DBF database to vector map, use "VALUE" as the key column
v.db.connect map=aas_z55 driver=dbf table=aas_z55 key=value

Done. The data are in GRASS GIS database.

Import E00 raster grids

Various hydrology and terrain analysis commands

See also

Wiki pages: