Importing data: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(+Troubleshooting of "ERROR: Projection of dataset does not appear to match current location")
 
(2 intermediate revisions by the same user not shown)
Line 5: Line 5:
The primary import/export tool is called [http://www.gdal.org GDAL/OGR]. It is the Rosetta Stone of the free GIS world:
The primary import/export tool is called [http://www.gdal.org GDAL/OGR]. It is the Rosetta Stone of the free GIS world:


* [http://www.gdal.org/formats_list.html Supported raster formats] via {{cmd|r.in.gdal}} (for example importing GeoTiffs)
* [http://www.gdal.org/formats_list.html Supported raster formats] via {{cmd|r.import}} (for example importing GeoTiffs)
* [http://www.gdal.org/ogr/ogr_formats.html Supported vector formats] via {{cmd|v.in.ogr}} (for example importing Shapefiles)
* [http://www.gdal.org/ogr/ogr_formats.html Supported vector formats] via {{cmd|v.import}} (for example importing Shapefiles)


=== Creating a new location from a data set ===


Create a new location for your data with the correct map projection using the Location Wizard on the main startup screen^, then in the menus:
'''New users:''' simply use the [[GRASS Location Wizard]].
Raster formats:  File → Import raster data using GDAL
Vector formats:  File → Import vector data using OGR


Typically GDAL/OGR will automatically detect the file format for you.
'''Background:'''
 
* [^] You must create a new GRASS ''location'' for each map projection you will work with or import data from. If you want the data reprojected into something else you'll have to create that target map projection in a ''location'' and pull them into there with {{cmd|r.proj}} and {{cmd|v.proj}}, or use [[GDAL]]'s <tt>gdalwarp</tt> or <tt>ogr2ogr</tt> command line tools.
: [''read more about this on the {{cmd|projectionintro}} help page'']


Create a new location for your data with the correct map projection using the Location Wizard on the main startup screen^, then in the menus (typically GDAL/OGR will automatically detect the file format for you):
* Raster formats:  File &rarr; Import raster data (internally using GDAL)
* Vector formats:  File &rarr; Import vector data (internally using OGR)


'''Power users:'''
* [^] For each map projection you must create a new GRASS ''location''. If you want the data reprojected into something else you'll have to create that target map projection in a ''location'' and pull them into there with {{cmd|r.proj}} and {{cmd|v.proj}}, or use [[GDAL]]'s <tt>gdalwarp</tt> or <tt>ogr2ogr</tt> command line tools.
: ''read more about this on the {{cmd|projectionintro}} help page''
* Many [http://www.gpsbabel.org/capabilities.shtml GPS formats] can imported with [http://www.gpsbabel.org GPSBabel] as well using the {{cmd|v.in.gpsbabel}} tool.
* Many [http://www.gpsbabel.org/capabilities.shtml GPS formats] can imported with [http://www.gpsbabel.org GPSBabel] as well using the {{cmd|v.in.gpsbabel}} tool.
* CSV files from a spreadsheet can be imported with the {{cmd|v.in.ascii}} module.
* CSV files from a spreadsheet can be imported with the {{cmd|v.in.ascii}} module.
Line 24: Line 26:
** If your .csv file contains "quoted" strings containing commas, you can use the [[AddOns#Miscellaneous_Add-ons|csv_dequote.pl]] script to parse them into a less-problematic form ready for import with {{cmd|v.in.ascii}}.
** If your .csv file contains "quoted" strings containing commas, you can use the [[AddOns#Miscellaneous_Add-ons|csv_dequote.pl]] script to parse them into a less-problematic form ready for import with {{cmd|v.in.ascii}}.


 
=== What's next after creating a new location from a data set ===
After the map has been imported you can add it to the display layer list in the Layer Manager window. You will most likely want to right click on the map in the layer list and select "Zoom to selected map(s)". Otherwise when you go to view the map you could be far away and just see a white display canvas.
After the map has been imported you can add it to the display layer list in the Layer Manager window. You will most likely want to right click on the map in the layer list and select "Zoom to selected map(s)". Otherwise when you go to view the map you could be far away and just see a white display canvas.


Line 84: Line 86:


=== Modules ===
=== Modules ===
Besides the standard tools {{cmd|r.import}} and {{cmd|v.import}}, GRASS GIS provides some addition specialized import tools for specific formats:
==== Raster ====
==== Raster ====
* {{cmd|r.in.arc}}
* {{cmd|r.in.arc}}

Latest revision as of 11:50, 20 January 2023

Getting your data into GRASS

GRASS supports many common GIS formats, and many uncommon ones too.

The primary import/export tool is called GDAL/OGR. It is the Rosetta Stone of the free GIS world:

Creating a new location from a data set

New users: simply use the GRASS Location Wizard.

Background:

Create a new location for your data with the correct map projection using the Location Wizard on the main startup screen^, then in the menus (typically GDAL/OGR will automatically detect the file format for you):

  • Raster formats: File → Import raster data (internally using GDAL)
  • Vector formats: File → Import vector data (internally using OGR)

Power users:

  • [^] For each map projection you must create a new GRASS location. If you want the data reprojected into something else you'll have to create that target map projection in a location and pull them into there with r.proj and v.proj, or use GDAL's gdalwarp or ogr2ogr command line tools.
read more about this on the projectionintro help page
  • Many GPS formats can imported with GPSBabel as well using the v.in.gpsbabel tool.
  • CSV files from a spreadsheet can be imported with the v.in.ascii module.
    (v.in.ogr could too, but it's not as smooth)
    • If your .csv file contains "quoted" strings containing commas, you can use the csv_dequote.pl script to parse them into a less-problematic form ready for import with v.in.ascii.

What's next after creating a new location from a data set

After the map has been imported you can add it to the display layer list in the Layer Manager window. You will most likely want to right click on the map in the layer list and select "Zoom to selected map(s)". Otherwise when you go to view the map you could be far away and just see a white display canvas.

To view a raster map, add it to the Layer Manager with the grid-like button with a (+), to add a vector map to the Layer Manager use the button with lines and points on it to the right of the add raster map button. The left hand button in the Map Display window will re-render the map if needed.

The "computational region" is a very important concept in GRASS and is distinct from the "display window" you see in the Map Display window. You can also read about it in the rasterintro help page. You can set the computational region and cell resolution to match a specific map with the g.region module.

After importing your data you need to run "g.region -p rast=your_map" or "g.region -p vect=your_map" to set the region bounds/zoom to match that of the newly imported map. Be careful with the region resolution when doing this with vector maps, you may have to run "g.region -a res=" to clean that up and keep it reasonable (for example 2000x2000 rows and columns).

Import Video Tutorials

External links

You can just link to the data rather than importing them.

  • r.external: full support for external raster data (all GDAL supported formats)
  • v.external: basic support for external vector data with some topology limitations (all OGR supported formats)

Bulk data import

The wxGUI menu tools offer simplified import.

Importing multiple vector (e.g., SHAPE) files

Bulk import of vector files via menu
Bulk import of multiple SHAPES via menu (files are auto-selected)

Importing multiple raster (e.g., GeoTIFF) files

Bulk import of GeoTIFF via menu
Bulk import of GeoTIFF via menu (files are auto-selected)

Large data

When importing large raster maps with r.in.gdal the default internal settings may be slow, with a large percentage of the CPU locked up in kernel system operations. In these cases you should increase the memory= option to be larger than:

tile_height * raster_width * band_count * sizeof_datatype

You can find those values with gdalinfo.

Setting the r.in.gdal memory= option has the same effect as setting the GDAL_CACHEMAX environment variable.

Modules

Besides the standard tools r.import and v.import, GRASS GIS provides some addition specialized import tools for specific formats:

Raster

Vector and points

Data formats

Troubleshooting

Q: GRASS GIS is giving an "ERROR: Projection of dataset does not appear to match current location". What should I do ?

A: In GRASS GIS, each location can have only one projection (to avoid quality loss in projection-on-the-fly approaches). To create a new location from the data set, simply use the GRASS Location Wizard.