Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new location and reprojection instructions for GRASS GIS #40

Open
wenzeslaus opened this issue May 5, 2018 · 0 comments
Open

Add new location and reprojection instructions for GRASS GIS #40

wenzeslaus opened this issue May 5, 2018 · 0 comments

Comments

@wenzeslaus
Copy link
Member

This is a topic which is still missing in the intro material for the course. There is grass/import.html which gives some hints about import. Perhaps this page can be extended.

Here is GRASS Clinic 2013 material from file NewLocCSTransfGRASS.html which was originally linked in an older version of the course (commented out text removed in 9609729):

GRASS GIS: How to get started with a new project and how to reproject data

Topic: starting a new project, reprojecting data

Before starting with GRASS it is important to understand that GRASS uses the concept of LOCATION, MAPSET, and region to support efficient analysis and modeling without the need to subset and resample data. LOCATION is a project data set that has common coordinate system. Each LOCATION can have several MAPSETS, one is called PERMANENT to store baseline data and coordinate system information, others are set by users. You can modify the data only in your current MAPSET, but you can view or copy data from other MAPSETS.

Setting up a new LOCATION

Create a directory for your downloaded external data, for example, C:\Users\myname\external
Download and unzip data in geographic coordinates (lat/long) into this directory: NC boundaries shape file bound23.shp ,
world boundaries, SRTM DEM tiles and GLOBCOVER tile from here: *ll.zip files
For snapshots of the interface see GRASS Location Wizard wiki page


# Create a new LOCATION when you have data with projection information
# in a format that is recognized by GDAL/OGR, for example, a georeferenced shape file or geotiff 
# Start GRASS by clicking on the GRASS icon

grass70

# in startup pannel
# for GIS data directory set path to your GRASS data sets
# click Location wizard to Define new LOCATION 
# In Define GRASS Database and Location name
#    Type a name of your new location into Project Location: world_latlong
#    Type a location title (optional): Worldwide data in geographic coordinates
# In Choose method select 
#    "Read projection and datum from a georeferenced data file"
# In Select georeferenced file
#    Browse to the downloaded shape file bound23.shp
# In Summary Click Finish
# for Import data Click Yes to import the data into new location and set the default region
# Click OK on the message that data were imported successfully and GRASS opens in the new LOCATION
#
# check the coordinate system

g.proj -p

# check your region

g.region -p

# the default region should be set to the imported file
# your can view the file by Add vector>bound23

d.vect map=bound23 type=boundary co=blue

#  change the resolution to 30 arc seconds

g.region res=0:00:30 -ap

# you can import data from any place in the world or for the entire world into this location 
# as long as they are in geographic coordinate system WGS84
# just set the region to your imported data and you are set to go.
# some examples from around the world:
# Import worldwide country boundaries, SRTM DEM for Netherlands, land cover for Central America
# File>Import vector data>common vector formats
# keep File and ESRI shape file on, browse to external/world_bound/country.shp
# click override data set projection becuase this data set lacks prj file
# click Import
# note: click on command dialog for more options and to generate the v.in.ogr command
# File>Import raster>common raster formats>select ASCII gridded XYZ
# browse to external/srtm_37_02/srtm_37_02.asc
# click Import
# File>Import raster>common raster formats>select Arc binary grid
# browse to external/srtm_nc_ll/w001001.adf
# click Import
# File>Import raster>common raster formats>GeoTIFF 
# browse to external/GLOBCOVER_200412_200606_V2.2_CentralAmerica_Reg.tif
# change the name for output to something shorter, for example, globcover_2004_ctramerica
# click Import

v.in.ogr -o dsn=/Users/helena/external/world_bound/country.shp output=country
r.in.gdal input=/Users/helena/external/srtm_37_02/srtm_37_02.asc output=srtm_37_02
r.in.gdal input=/Users/helena/external/srtm_nc_ll/w001001.adf output=srtm_nc
r.in.gdal input=/Users/helena/external/GLOBCOVER_200412_200606_V2.2_CentralAmerica_Reg.tif output=globcover_2004_ctramerica

# to view an imported map, switch it on in layer manager, select it and 
# Zoom to selected layer in map display 
# 

d.vect country type=boundary
d.rast srtm_37_02
d.rast srtm_nc

You can now reproject data between geographic coordinate system and NC State Plane system

To reproject data using GRASS LOCATIONS you must have LOCATIONs in both coordinate systems. If you have a coordinate system different from the ones provided in this course, use the LOCATION wizard in GRASS64 startup pannel to create a new LOCATION.


# grassbook p.47
# start GRASS with world_latlong LOCATION, mapset PERMANENT
# create a vector polygon outlining the spatial extent of your raster
# so that you can use it to set the region when projecting to state plane
# because r.proj projects only the subset of a raster map that is within the defined region

g.region rast=srtm_nc
v.in.region srtm_nc_region

# you can exit GRASS with world_latlong now
#
# start new GRASS session with the nc_spm _08 LOCATION
# project your lat/long data from world_latlong into nc_spm_08
# Vector>Develop vector map>Reproject vector map opens the v.proj GUI
# for Location containing input select world_latlong
# Source pannel > start with "Path to GRASS database">Browse to grassdata
# for Mapset select PERMANENT, Name of input > bound23> Run
# repeat same with srtm_nc_region
# run it through wxGUI, below is command line equivalent

v.proj bound23 location=world_latlong mapset=PERMANENT dbase=/Users/helena/grassdata out=nc_boundary
v.proj srtm_nc_region location=world_latlong mapset=PERMANENT dbase=/Users/helena/grassdata

# for the raster map, set the region using the projected region polygon
# convert the resolution in arc seconds to meters to set the resolution
# 1 arcsec ~ 30m, 1/3 arcsec ~ 10m

g.region vect=srtm_nc_region res=30 -p
r.proj srtm_nc location=world_latlong mapset=PERMANENT dbase=/Users/helena/grassdata out=srtm_nc_30m method=bilinear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant