Difference between revisions of "Tips for Arc users"

From GRASS-Wiki
Jump to navigation Jump to search
m (Added one additional item under hydrology)
Line 48: Line 48:


==== Various vector operations ====
==== Various vector operations ====
* Editing differences
* Editar diferencias
: Tips for [[Digitizing_Area_Features|Digitizing area features with attributes]]
: Tips para la [[Digitizing_Area_Features|digitalización de áreas con atributos]]


=== Raster import/export ===
=== Importación/exportación de rásters ===
 
* {{cmd|r.in.gdal}} - Importa archivos ráster a un soportados por [http://www.gdal.org GDAL] a una capa de mapa ráster binaria.
** Importar una malla binaria ArcInfo a GRASS:
*** Ver la [http://www.gdal.org/frmt_various.html#AIG página de GDAL para AIC]
*** Usualmente el archivo .adf más grande es el que se debe importar -- revise los valores de sus datos luego de realizar la importación aun cuando sean visualmente correctos.


* {{cmd|r.in.gdal}} - Import [http://www.gdal.org GDAL] supported raster file into a binary raster map layer.
** Import a binary ArcInfo raster grid into GRASS:
*** See the [http://www.gdal.org/frmt_various.html#AIG 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.in.gdal input=/path/to/map/hdr.adf output=map


* {{cmd|r.out.gdal}} - Exports GRASS raster data into various formats.
* {{cmd|r.out.gdal}} - Exporta datos ráster a varios formatos.
** Export a raster as a GeoTIFF for use with ArcView 3.1:
** Exportar un ráster como un GeoTIFF para usarlo en ArcView 3.1:
  r.out.gdal input=map output=map.tif type=Byte createopt="INTERLEAVE=PIXEL,COMPRESS=PACKBITS"
  r.out.gdal input=map output=map.tif type=Byte createopt="INTERLEAVE=PIXEL,COMPRESS=PACKBITS"


==== Import ArcASCII raster grid and connect to database ====
==== Importar malla ráster ArcASCII y conectar a la base de datos ====


The trick is to convert the raster coverage to vector
El truco está en convertir la cobertura ráster a áreaas vectoriales para sacar ventaja del manejo atributos/bases de datos de los vectoriales en GRASS. Puede usar el comando {{cmd|r.in.gdal}} para importar.
areas to take advantage of GRASS's rich vector attribute/database tie-ins. You can use {{cmd|r.in.gdal}} for the import.


  # import ArcASCII grid to UTM55S location
  # importar malla  ArcASCII a una localización UTM55S
  r.in.gdal  input=aas_z55.asc output=aas_z55
  r.in.gdal  input=aas_z55.asc output=aas_z55
  r.colors aas_z55.gdal color=random
  r.colors aas_z55.gdal color=random
  r.info aas_z55
  r.info aas_z55
   
   
  # convert to vector areas, using raster value for category
  # convertir a áreas vectoriales, usando los valores del ráster como categorías
  g.region rast=aas_z55
  g.region rast=aas_z55
  r.to.vect -v in=aas_z55.gdal out=aas_z55 feature=area
  r.to.vect -v in=aas_z55.gdal out=aas_z55 feature=area
   
   
  # get rid of empty DBF table created by r.to.vect
  # deshacerse de la tabla vacía creada
  v.db.droptable aas_z55
  v.db.droptable aas_z55
   
   
  # copy real DBF file into $MAPSET/dbf/ directory
  # copiar la tabla real al directorio $MAPSET/dbf/
  eval `g.gisenv`
  eval `g.gisenv`
  cp /tmp/au/aas_z55.DBF "$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/aas_z55.dbf"
  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
  # conectar la base de datos completa al mapa vectorial, usar como columna clave la columna "VALUE"
  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. The data are in GRASS GIS database.
Y listo. Los datos están en la base de datos de GRASS.
 
==== 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.gdal}}.
* [http://lists.osgeo.org/pipermail/grass-user/2009-October/052758.html See instructions in this mailing list post] about the "ArcExplorer Import Utility"
 
== Linking data to GRASS GIS ==
 
You can link data instead of importing them, use {{cmd|r.external}}, {{cmd|v.external}}, {{cmd|r.external.out}}, and {{cmd|v.external.out}}. Projection of all data must be consistent.
 
== Various hydrology and terrain analysis commands ==


<!-- perhaps this should go to GRASS GIS for ArcGIS users page -->
==== Importar mallas ráster E00 ====
<!-- but in general, this page could contains some common usecases which includes hydrology -->
* El módulo {{cmd|v.in.e00}} solamente manipula datos vectoriales. Debe convertir los datos ráster E00 al formato Arc ASCII antes de importar a GRASS con el comando {{cmd|r.in.gdal}}.
* [http://lists.osgeo.org/pipermail/grass-user/2009-October/052758.html Ver las instrucciones en el correo] sbre la "ArcExplorer Import Utility".


* Watershed modeling differences:
== Enlazar datos en GRASS ==
** ArcInfo wants a depressionless, filled, hydrologically correct DEM.
** {{cmd|r.watershed}} does not need such a DEM, it is happy with a raw DEM even containing depressions, being not filled, and not hydrologically correct (hence, no extra preparations needed!).
* How to [[Creating_watersheds|Create watersheds for specific drainage points]] like the Arc Hydro extension
* See also [[Hydrological Sciences]] for a list of available hydrological GRASS tools
* [http://www.surfaces.co.il/?p=241 Watershed Analysis with GRASS] (when you know ESRI)
* [https://grasswiki.osgeo.org/wiki/Creating_watersheds#Calculating_total_drainage_area_for_each_stream_reach Calculating total upstream area for each stream]


== See also ==
Es posible enlazar los datos, en vez de importarlos usando los comandos {{cmd|r.external}}, {{cmd|v.external}}, {{cmd|r.external.out}}, y  {{cmd|v.external.out}}. Todos los datos deben tener la misma proyección que la Localización de GRASS.== See also ==


* [[GRASS GIS for ArcGIS users]]
* [[GRASS GIS for ArcGIS users]]
* [[Terminology comparison between ArcGIS and GRASS GIS]]
* [[Terminology comparison between ArcGIS and GRASS GIS]]


== External links ==
== Links externos ==


* Basic [http://geostat-course.org/Topic_NetelerMetz_2012 GRASS GIS tutorial] at Geostat 2012
* Tutorial básci de GRASS en Gostat 2012 (y otros años) [http://geostat-course.org/Topic_NetelerMetz_2012 Tutorial de GRASS GIS].
* [http://www.appropedia.org/A_transition_from_ArcGIS_to_open_source_GIS_softwares A transition from ArcGIS to open source GIS softwares]
* [http://www.appropedia.org/A_transition_from_ArcGIS_to_open_source_GIS_softwares Transición desde ArcGIS a SIGs libres].
* [http://gis.stackexchange.com/questions/134/can-arcgis-and-osgeo4w-share-the-same-python-install Can ArcGIS and OSGeo4W share the same python install?]
* [http://gis.stackexchange.com/questions/134/can-arcgis-and-osgeo4w-share-the-same-python-install Can ArcGIS and OSGeo4W share the same python install?]



Revision as of 04:58, 22 July 2016

If you wish to use both GRASS GIS and ArcGIS together, this page is for you.

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

  • 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 operations

  • Editar diferencias
Tips para la digitalización de áreas con atributos

Importación/exportación de rásters

  • r.in.gdal - Importa archivos ráster a un soportados por GDAL a una capa de mapa ráster binaria.
    • Importar una malla binaria ArcInfo a GRASS:
      • Ver la página de GDAL para AIC
      • Usualmente el archivo .adf más grande es el que se debe importar -- revise los valores de sus datos luego de realizar la importación aun cuando sean visualmente correctos.
r.in.gdal input=/path/to/map/hdr.adf output=map
  • r.out.gdal - Exporta datos ráster a varios formatos.
    • Exportar un ráster como un GeoTIFF para usarlo en ArcView 3.1:
r.out.gdal input=map output=map.tif type=Byte createopt="INTERLEAVE=PIXEL,COMPRESS=PACKBITS"

Importar malla ráster ArcASCII y conectar a la base de datos

El truco está en convertir la cobertura ráster a áreaas vectoriales para sacar ventaja del manejo atributos/bases de datos de los vectoriales en GRASS. Puede usar el comando r.in.gdal para importar.

# importar malla  ArcASCII a una localización UTM55S
r.in.gdal  input=aas_z55.asc output=aas_z55
r.colors aas_z55.gdal color=random
r.info aas_z55

# convertir a áreas vectoriales, usando los valores del ráster como categorías
g.region rast=aas_z55
r.to.vect -v in=aas_z55.gdal out=aas_z55 feature=area

# deshacerse de la tabla vacía creada
v.db.droptable aas_z55

# copiar la tabla real al directorio $MAPSET/dbf/
eval `g.gisenv`
cp /tmp/au/aas_z55.DBF "$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/aas_z55.dbf"

# conectar la base de datos completa al mapa vectorial, usar como columna clave la columna "VALUE"
v.db.connect map=aas_z55 driver=dbf table=aas_z55 key=value

Y listo. Los datos están en la base de datos de GRASS.

Importar mallas ráster E00

Enlazar datos en GRASS

Es posible enlazar los datos, en vez de importarlos usando los comandos r.external, v.external, r.external.out, y v.external.out. Todos los datos deben tener la misma proyección que la Localización de GRASS.== See also ==

Links externos