[GRASS-user] r.proj: Regions Do Not Match

   I am trying to reproject all data to a single projection: Albers Equal
Area (NAD83) and g.region is:

projection: 99 (Albers Equal Area)
zone: 0
datum: nad83
ellipsoid: grs80
north: 43
south: 34
west: -121
east: -112
nsres: 1
ewres: 1
rows: 9
cols: 9
cells: 81

   The DEMs were originally in lat/lon (NAD83) and imported to that location.
When I try to reproject them I see that the regions do not match. For
example:

GRASS 6.5.svn (Nevada-aea):~/grassdata > r.proj in=dem_area15
location=Nevada-ll mapset=PERMANENT method=cubic_f
Input Projection Parameters: +proj=longlat +no_defs +a=6378137
+rf=298.257222101 +towgs84=0,0,0,0,0,0,0
Input Unit Factor: 1
Output Projection Parameters: +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23
+lon_0=-96 +x_0=0 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0,0,0,0,0,0,0
Output Unit Factor: 1
ERROR: Input raster map is outside current region

   Running r.proj -p produces:

GRASS 6.5.svn (Nevada-aea):~/grassdata > r.proj -p in=dem_area15
location=Nevada-ll mapset=PERMANENT method=cubic_f
Input Projection Parameters: +proj=longlat +no_defs +a=6378137
+rf=298.257222101 +towgs84=0,0,0,0,0,0,0
Input Unit Factor: 1
Output Projection Parameters: +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23
+lon_0=-96 +x_0=0 +y_0=0 +no_defs +a=6378137 +rf=298.257222101
+towgs84=0,0,0,0,0,0,0
Output Unit Factor: 1
Input map <dem_area15@PERMANENT> in location <Nevada-ll>:
Source cols: 3600
Source rows: 3600
Local north: 2064411.8954923
Local south: 1973182.43184852
Local west: -1787211.15607592
Local east: -1679987.035036

   Is this a result of user error? If so, do I re-import these data? If not,
what do I need to do to get all these data into a single location?

Rich

Rich wrote:

  I am trying to reproject all
data to a single projection: Albers Equal
Area (NAD83) and g.region is:

projection: 99 (Albers Equal Area)
zone: 0
datum: nad83
ellipsoid: grs80
north: 43
south: 34
west: -121
east: -112
nsres: 1
ewres: 1
rows: 9
cols: 9
cells: 81

  The DEMs were originally in lat/lon (NAD83) and
imported to that location.

if the originals are lat/lon then they need to be imported to a lat/lon
location, not a projected Albers location. pull them in from the lat/lon
location to the AEA location with r.proj if needed. I think you've already
done this, but the region bounds above don't look very Albers-like.

Albers will be in meters (or feet) -- Cartesian units.
Lat/lon will be in degrees -- angular units.
those don't mix without a projection.

GRASS 6.5.svn (Nevada-aea):~/grassdata > r.proj in=dem_area15
location=Nevada-ll mapset=PERMANENT method=cubic_f

...

ERROR: Input raster map is outside current region

  Running r.proj -p produces:

GRASS 6.5.svn (Nevada-aea):~/grassdata > r.proj -p in=dem_area15
location=Nevada-ll mapset=PERMANENT method=cubic_f
Input Projection Parameters: +proj=longlat +no_defs
+a=6378137
+rf=298.257222101 +towgs84=0,0,0,0,0,0,0
Input Unit Factor: 1
Output Projection Parameters: +proj=aea +lat_1=29.5
+lat_2=45.5 +lat_0=23
+lon_0=-96 +x_0=0 +y_0=0 +no_defs +a=6378137
+rf=298.257222101
+towgs84=0,0,0,0,0,0,0
Output Unit Factor: 1
Input map <dem_area15@PERMANENT> in location
<Nevada-ll>:
Source cols: 3600
Source rows: 3600
Local north: 2064411.8954923
Local south: 1973182.43184852
Local west: -1787211.15607592
Local east: -1679987.035036

  Is this a result of user error? If so, do I
re-import these data? If not,
what do I need to do to get all these data into a single
location?

ok, that looks good, although I wonder why the east and west have become
negative.

r.proj pulls into the current region bounds, so try this step first, taking
bounds from "r.proj -p" output above: ('r.proj -g' is handy for that)

g.region n=2064411.8954923 s=1973182.43184852 e=-1679987.035036 \
   -p w=-1787211.15607592 rows=3600 cols=3600

which gives you:
nsres: 25.34151768
ewres: 29.78447807

maybe then try to round the resolution and bounds:
  g.region -a -p nsres=25 ewres=30

or both to 30m (or ft) if you prefer nice squares.

usually I try to have no less than the same number of rows and columns as
the original map, and if the convergence angle between the two projections
is large (g.region -n) add more rows+cols to compensate for the rotation.

once you are happy with the target resolution/bounds, only then run
r.proj to pull in the other map -into the current region box-.

you're very close,
Hamish

On Wed, 2 Mar 2011, Hamish wrote:

  The DEMs were originally in lat/lon (NAD83) and imported to that
location.

if the originals are lat/lon then they need to be imported to a lat/lon
location,

   As stated.

ok, that looks good, although I wonder why the east and west have become
negative.

   Let's deal with that later. I see a problem with the region on my lon/lat
location:

GRASS 6.5.svn (Nevada-ll):~/grassdata > g.region -p
projection: 3 (Latitude-Longitude)
zone: 0
datum: nad83
ellipsoid: grs80
north: 1N
south: 0
west: 0
east: 1E
nsres: 1
ewres: 1
rows: 1
cols: 1
cells: 1

   So, I do this:

GRASS 6.5.svn (Nevada-ll):~/grassdata > g.list rast
----------------------------------------------
raster files available in mapset <PERMANENT>:
dem_area15 dem_area2 dem_area3 dem_area8 dem_area9

Then set the region to dem_area2 (as a first step). This yields:

GRASS 6.5.svn (Nevada-ll):~/grassdata > g.region -p
projection: 3 (Latitude-Longitude)
zone: 0
datum: nad83
ellipsoid: grs80
north: 42N
south: 41N
west: 116W
east: 115W
nsres: 0:00:01
ewres: 0:00:01
rows: 3600
cols: 3600
cells: 12960000

   Ah-h-h! That's better.

And now when I run r.proj it works. Why the AEA location has negative east
and west values I cannot explain.

   Conclusion: I did not set the region in the long/lat location based on an
existing map so it had random and meaningless numbers.