Re: [gdal-dev] Question about using crop_to_cutline

2012-10-26 Thread Jukka Rahkonen
Even Rouault even.rouault at mines-paris.org writes:


 This is the very same topic that is discussed in 
 http://trac.osgeo.org/gdal/ticket/3947 . There's no solution to your problem, 
 but some background discussion that explains the current behaviour.

This is close to a problem I had once with creating mosaics from individually
warped orthophotos. Accurately calculated extents make pixels to slide a bit and
individually warped images do not share any common canvas for their pixels. I
sketched a plan for forcing the warped image to use a common canvas and found a
python guy to make a program. I have been satisfied with the result.

I believe that the same solution will work for you. You must widen the -te
parameters that is calculated by crop_to_cutline to each direction so that they
match exactly with some pixel row and line of the original image. See figures 3,
4, and 5 in http://www.scangis.org/scangis2007/papers/r3_rahkonen.pdf. The
python code is there too. Without understanding anything about programming I
suppose that the job is done with this:

minmax = get_minmax(tm32_coords)
minmax_wider = [
(int(math.floor(minmax[0][0])), int(math.floor(minmax[0][1]))),
(int(math.ceil (minmax[1][0])), int(math.ceil (minmax[1][1]))),
]

log(Extents (min,max):  + str(minmax), outfilename)
log(Widened extents (min,max):  + str(minmax_wider), outfilename)

-Jukka Rahkonen-

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Question about using crop_to_cutline

2012-10-26 Thread Marius Jigmond
At the time I created the ticket I had created a workaround that uses 
gdal_translate to clip a rectangular window and gdal_rasterize to burn an 
inverse image of the vector. Interested folks can email me for the script (does 
the list take attachments?). The script makes some assumptions about your data 
type (e.g. 0 is assigned as nodata) but you can change those assumptions to 
suit your needs.
I plan to make the feature request I mentioned in #3947.
-marius
 To: gdal-dev@lists.osgeo.org
 From: jukka.rahko...@mmmtike.fi
 Date: Fri, 26 Oct 2012 09:05:06 +
 Subject: Re: [gdal-dev] Question about using crop_to_cutline
 
 Even Rouault even.rouault at mines-paris.org writes:
 
 
  This is the very same topic that is discussed in 
  http://trac.osgeo.org/gdal/ticket/3947 . There's no solution to your 
  problem, 
  but some background discussion that explains the current behaviour.
 
 This is close to a problem I had once with creating mosaics from individually
 warped orthophotos. Accurately calculated extents make pixels to slide a bit 
 and
 individually warped images do not share any common canvas for their pixels. I
 sketched a plan for forcing the warped image to use a common canvas and found 
 a
 python guy to make a program. I have been satisfied with the result.
 
 I believe that the same solution will work for you. You must widen the -te
 parameters that is calculated by crop_to_cutline to each direction so that 
 they
 match exactly with some pixel row and line of the original image. See figures 
 3,
 4, and 5 in http://www.scangis.org/scangis2007/papers/r3_rahkonen.pdf. The
 python code is there too. Without understanding anything about programming I
 suppose that the job is done with this:
 
 minmax = get_minmax(tm32_coords)
   minmax_wider = [
   (int(math.floor(minmax[0][0])), int(math.floor(minmax[0][1]))),
   (int(math.ceil (minmax[1][0])), int(math.ceil (minmax[1][1]))),
   ]
 
   log(Extents (min,max):  + str(minmax), outfilename)
   log(Widened extents (min,max):  + str(minmax_wider), outfilename)
 
 -Jukka Rahkonen-
 
 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev
  ___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Question about using crop_to_cutline

2012-10-25 Thread Luis Lisboa
Hi

I have exacly the same problem. It is resampling to the extent of the
polygon instead of croping just the pixels inside the polygon and using the
pixel frame of the original image. How can this be fixed?
Regards
Luis Lisboa





- ORIGINAL MESSAGE--

Greetings

I have a raster image and a shapefile polygon and I wanted to crop the
raster for just to have valid pixels inside the polygon. I have used
crop_to_cutline but here is a problem:
It produces a raster map but pixels does not geographically match with
the original raster map. So, i produce a raster map but I'm not able to
compare with original image since there is a small displacement. How can
I obtain a raster map without this mismatch?
Thank you
Regards,
Antonio

GDAL version 1.9.1
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Question about using crop_to_cutline

2012-10-25 Thread Joaquim Luis
I have a close functionality in Mirone but it was developed mainly for 
grids, though it works also with images.
With a grid/image loaded, load the polygon too. Next right-click on the 
polygon line and select


ROI Crop Tools - Crop Image (or any of the other related options)

and it's done. One thing you may not like is that the resulting image is 
not of the same size (extent) as the original. This is so because I 
(don't remember anymore why) decided to save only the extent 
corresponding to the BoundingBox of the polygon.


Joaquim


Hi
I have exacly the same problem. It is resampling to the extent of the 
polygon instead of croping just the pixels inside the polygon and 
using the pixel frame of the original image. How can this be fixed?

Regards
Luis Lisboa
- ORIGINAL MESSAGE--
Greetings

I have a raster image and a shapefile polygon and I wanted to crop the
raster for just to have valid pixels inside the polygon. I have used
crop_to_cutline but here is a problem:
It produces a raster map but pixels does not geographically match with
the original raster map. So, i produce a raster map but I'm not able to
compare with original image since there is a small displacement. How can
I obtain a raster map without this mismatch?
Thank you
Regards,
Antonio

GDAL version 1.9.1


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev

Re: [gdal-dev] Question about using crop_to_cutline

2012-10-25 Thread António Rocha

Hi
Sorry Joaquim but I'm really trying to find a solution based on GDAL.
Thanks
Antonio

I have a close functionality in Mirone but it was developed mainly for 
grids, though it works also with images. With a grid/image loaded, 
load the polygon too. Next right-click on the polygon line and select 
ROI Crop Tools - Crop Image (or any of the other related options) and 
it's done. One thing you may not like is that the resulting image is 
not of the same size (extent) as the original. This is so because I 
(don't remember anymore why) decided to save only the extent 
corresponding to the BoundingBox of the polygon. Joaquim 


___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


Re: [gdal-dev] Question about using crop_to_cutline

2012-10-25 Thread Even Rouault
Le mercredi 24 octobre 2012 17:19:45, António Rocha a écrit :
 Greetings
 
 I have a raster image and a shapefile polygon and I wanted to crop the
 raster for just to have valid pixels inside the polygon. I have used
 crop_to_cutline but here is a problem:
 It produces a raster map but pixels does not geographically match with
 the original raster map. So, i produce a raster map but I'm not able to
 compare with original image since there is a small displacement. How can
 I obtain a raster map without this mismatch?

This is the very same topic that is discussed in 
http://trac.osgeo.org/gdal/ticket/3947 . There's no solution to your problem, 
but some background discussion that explains the current behaviour.

 Thank you
 Regards,
 Antonio
 
 GDAL version 1.9.1
 ___
 gdal-dev mailing list
 gdal-dev@lists.osgeo.org
 http://lists.osgeo.org/mailman/listinfo/gdal-dev
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev


[gdal-dev] Question about using crop_to_cutline

2012-10-24 Thread António Rocha

Greetings

I have a raster image and a shapefile polygon and I wanted to crop the 
raster for just to have valid pixels inside the polygon. I have used 
crop_to_cutline but here is a problem:
It produces a raster map but pixels does not geographically match with 
the original raster map. So, i produce a raster map but I'm not able to 
compare with original image since there is a small displacement. How can 
I obtain a raster map without this mismatch?

Thank you
Regards,
Antonio

GDAL version 1.9.1
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/gdal-dev