[GRASS5] [bug #3876] (grass) g.proj: proj4= fails, wkt= works partialy

Paul Kelly paul-grass at stjohnspoint.co.uk
Sun Dec 4 11:18:35 EST 2005


Request Tracker wrote:
> I wanted to change it with "g.proj wkt=wkt_file". It kindoff works, but:
> 1. the PERMANENT/WIND and PERMANENT/DEFAULT_WIND are left unchanged (still refer to latlong).
> 2. only the WIND in working mapset is changed properly
> 3. surprisingly, a correct DEFAULT_WIND appears in current working mapset - but it should go to PERMANENT.

I take it you mean "g.proj -c wkt=wkt_file". You are right in that it 
won't work properly if you are not in the PERMANENT mapset. You need to 
have write access to the PERMANENT mapset anyway if you are going to 
change the projection files. I think changing the projection is a 
dramatic-enough thing to do to require the user to have selected the 
PERMANENT mapset before doing this, so I have changed g.proj to exit 
with an error if the user is not in PERMANENT.

This functionality (overwrite existing projection files) was not well 
tested; I have noticed also that the region was overwritten every time 
regardless of whether it had changed or not (if projection changed 
between UTM, XY, latlong or other, or if the zone changed {i.e. to or 
from UTM or changing UTM zone}). So if none of those change then the 
region file doesn't need to be changed and it won't change it. (Ideally 
of course the region file should not hold projection information but it 
is a legacy "feature" that it does and it is not really feasible to 
change it at this stage.)

If you have more multiple mapsets and the default region changes, you 
will need to run "g.region -d" in each mapset to update the region. This 
is another "feature" and also holds for g.setproj. I've changed g.proj 
so it will output a warning if you're likely to need to run g.region -d.

> Trying to change a projection to a following PROJ.4 description:
> 
> GRASS 6.1.cvs (huha2):~ > cat puwg1965_IV.prf
> +proj=sterea +lat_0=50.625 +lon_0=21.08333333333333 +k=0.9998 +x_0=4637000 +y_0=5467000 +ellps=krass +towgs84=33.4297,-146.5746,-76.2865,-0.35867,-0.05283,0.84354,-0.84077 +units=m
> 
> 
> 
> It fails, no change is done:
> 
> GRASS 6.1.cvs (huha2):~ > g.proj -c proj4=puwg1965_IV.prf

That should not work and should give an error (but would not have). I've 
fixed the return code checking so that it does. You need to run it like:
cat puwg1965_IV.prf | g.proj -c proj4=-
it is like that because PROJ.4-style descriptions are likely to be much 
shorter and more feasible to type on the command line than to read in 
from a file, and means you can do neat things with init codes and EPSG 
numbers easily. With the input wkt option that would of course work (it 
reads from a file there).
See the man page for more examples:
http://grass.itc.it/grass61/manuals/html61_user/g.proj.html

Paul




More information about the grass-dev mailing list