[GRASSLIST:7178] Re: crop of raster - once again

Axel Orth axel_orth at gmx.de
Thu Jun 16 02:53:18 EDT 2005


Ian MacMillan schrieb:

> I guess I don't understand your problem, it looks like you have the 
> area inside the masked boundary as a cropped map, assumably with just 
> one value for all the pixels.  This isn't what you wanted?
>
> -ian
>
> On Jun 15, 2005, at 1:50 PM, Axel Orth wrote:
>
>> Ian MacMillan schrieb:
>>
>>> Hmm, this sounds like weird behavior with the mask function, which 
>>> version of grass are you using?  Another possibility in the meantime 
>>> is this:
>>> r.mapcalc MAP_crop = 'if(isnull(MASK), null(), MAP)'
>>>
>>> -Ian
>>>
>>> On Jun 15, 2005, at 11:42 AM, Axel Orth wrote:
>>>
>>>> Axel Orth schrieb:
>>>>
>>>>> Ian MacMillan schrieb:
>>>>>
>>>>>> Axel, you might try
>>>>>> r.mapcalc MASK='if(V_rast=0, null(), 1)'
>>>>>>
>>>>>> I am not sure if this will work, but it is worth a try.
>>>>>>
>>>>>> G'luck,
>>>>>> -Ian
>>>>>>
>>>>>> On Jun 15, 2005, at 6:57 AM, Axel Orth wrote:
>>>>>>
>>>>>>> Hey,
>>>>>>> I had some success with cropping my raster maps with borders of 
>>>>>>> municipalities (available as vector - converted to raster) and 
>>>>>>> thought I figured out how it works.
>>>>>>>
>>>>>>> But now I try do do the same with some other data and strange 
>>>>>>> things happen:
>>>>>>>
>>>>>>> import raster map "MAP" - import vector "V" - do raster 
>>>>>>> conversation with vector and get the raster map "V_rast"
>>>>>>> set the region: g.region rast=V_rast zoom=V_rast
>>>>>>> create the mask: g.copy V_rast,MASK
>>>>>>> create new map based on the existing map while only the area of 
>>>>>>> the mask is taken into consideration: r.mapcalc MAP_crop=MAP
>>>>>>>
>>>>>>> Problem: the resulting map MAP_crop is just a colored rectangle 
>>>>>>> - the size of the rectangle is equal to the bounding box of V_rast
>>>>>>>
>>>>>>> By chance I made some errors and somehow got the result i wanted:
>>>>>>> instead of the r.mapcalc command shown above I did:
>>>>>>>
>>>>>>> r.mapcalc
>>>>>>> MAP_crop=MAP end -> syntax error
>>>>>>> r.mapcalc MAP_crop=MAP
>>>>>>>
>>>>>>> MAP looks now exactly the way I wanted. When I leave GRASS, 
>>>>>>> start again then MAP looks like I had when imported it.
>>>>>>>
>>>>>>> I have no clue what's this is all about and hope someone has a 
>>>>>>> idea.
>>>>>>>
>>>>>>>
>>>>>>> Regards
>>>>>>> Axel
>>>>>>>
>>>>>>
>>>>>>
>>>>> Hey Ian,
>>>>> thank you for the suggestion.
>>>>> I used that command between g.copy V_rast,MASK and r.mapcalc 
>>>>> MAP_crop=MAP but that did not change anything.
>>>>> Have I been supposed to use it that way? I don't work much with 
>>>>> GRASS but the command looks like it is about making sure that just 
>>>>> pixel that contain information are taken to create the mask. Is 
>>>>> that right?
>>>>>
>>>>> As it did not work out I looked at the MASK after your command and 
>>>>> it looked like this: see mask_2.gif - the result of r.mapcalc 
>>>>> MAP_crop=MAP looks also that way. Without your command, the MASK 
>>>>> looks like: mask.gif - this it the way the mask has to look. This 
>>>>> outline should become the new border for the cropped map.
>>>>>
>>>>> I hope the pictures make things a little easier to understand.
>>>>>
>>>>>
>>>>> Regards
>>>>> Axel
>>>>>
>>>>>
>>>> sorry, forgot the pictures
>>>> <mask_2.gif><mask.gif>
>>>
>>>
>>>
>>>
>> Hey,
>> I am using GRASS 6.1.cvs running on windows xp via cygwin. I think I 
>> got it from 
>> https://www.geographie.uni-freiburg.de/~mlechner/CygwinGRASS/
>>
>> I used your new command instead of my original r.mapcalc and the 
>> result was as follows:
>> MAP_crop: see MAP_crop.gif
>> So the new command did not change anything.
>> I need the cropped map outside of GRASS so I can just export the map 
>> while the MASK is still there and get a fitting result. But it would 
>> be better if the problem can be solved.
>>
>>
>> Regards
>> Axel
>>
>> <MAP_crop.gif>
>
>
>
I have to admit that I did not understand the problem when I posted the 
first question.
But due to the discussion things are more clear now.

I want a map that looks like: intended.gif
I have a rectangular map and the mask to crop it to look that way.
When I display the map and the mask is active, I get the result you see 
in the attachment. I am also able to export it. Everything is fine.
BUT
I think r.mapcalc cropped_map=map should give me that result as a new 
raster file and when I use that command the map becomes pink.

SO it is not such a big problem but still a little bit strange.


Regards
Axel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: intended.gif
Type: image/gif
Size: 13191 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20050616/1a110be3/intended.gif


More information about the grass-user mailing list