Martin, etc.:

Here are some givens, and some pseudocode.  The code below assumes two
arbitrary georeferencing points, which in your example would even be better,
because you could use the upper-left and lower-right corners of the polygon
as the shapefile's georeference points, and then use 0,0 and image width and
height as the image's georef points.

- Jim

%%%%%%%%%%%%%%%%%%%


Givens:

1)
Given an image world file is a plain ASCII text file with six lines:

A = width of an image pixel in map units (positive value)
D = rotation terms (in this particular simple case, always zero)
B = rotation terms (in this particular simple case, always zero)
E = height of an image pixel in map units (negative value)
C = X location of the center of the top-left pixel in map units
F = Y location of the center of the top-left pixel in map units

2)
Given a shapefile "Shp" with two registration points, each having X/Y values
in terms of its map units,
and an image "Img" with two registration points, each having X/Y values in
terms of its pixel coordinates,
with both pairs of registration points positioned in the same two relative
locations on each.

Best if the two registration points are as far away from each other as
possible, and best if registration point #2 is the furthest to the
lower-right of the extent.

3)
Given,
...an 0,0 origin of the shapefile's coordinate system is lower-left of +/+
quadrant.
...an 0,0 origin of the image is the pixel at the most top-left.

4)
Given you need a simple two-point transformation of the image *to* the
shapefile.  No change of projection, rotation, warping, etc.

Here:

Here is pseudocode for creating a world file...

*'1st line:  Width of a pixel in map units (must be positive)
dA = Abs(dShpRegPoint1.X - dShpRegPoint2.X) / Abs(lImgRegPoint1.X -
lImgRegPoint2.X)
*

*'2nd and 3rd lines:  Rotation terms (not needed in this particular simple
case)
dD = 0
dB = 0*
*

'4th line:  Height of a pixel in map units (must be negative)
dE = -(Abs(dShpRegPoint1.Y - dShpRegPoint2.Y) / Abs(lImgRegPoint1.Y -
lImgRegPoint2.Y))

'5th and 6th lines:  Location of center of top-left pixel in map units
dC = (dShpRegPoint2.X - (lImgRegPoint2.X * dA)) + (dA / 2)
dF = (dShpRegPoint2.Y + (lImgRegPoint2.Y * Abs(dE))) - (Abs(dE) / 2)
*%%%%%%%%%%%%%%%%%%%


On 5/28/09, Simone Giannecchini <[email protected]>
wrote:
>
> Actually,
> I am interested in putting together something similar.
> The new version of the mosaic plugin in geoserver does build the index
> itself, by pointing it at a directry. I need the ability to point it
> to an existing index shapefile and check it/convert it/create the
> ancillary files.
> This might overlap with you goals, therefore I am willing to help you out a
> bit.
>
> Simone.
> -------------------------------------------------------
> Ing. Simone Giannecchini
> GeoSolutions S.A.S.
> Owner - Software Engineer
> Via Carignoni 51
> 55041  Camaiore (LU)
> Italy
>
> phone: +39 0584983027
> fax:      +39 0584983027
> mob:    +39 333 8128928
>
>
> http://www.geo-solutions.it
> http://simboss.blogspot.com/
> http://www.linkedin.com/in/simonegiannecchini
>
> -------------------------------------------------------
>
>
>
> On Thu, May 28, 2009 at 10:06 AM, Martin Tomko <[email protected]>
> wrote:
> > Hi all,
> > hm, interesting to see that noone else needed this. Yes Simone, I think I
> > will hack it in geotools, package as an executable jar and make it
> > available...
> > Cheers  to everyone,
> > Martin
> >
> > Simone Giannecchini wrote:
> >>
> >> Ciao Martin,
> >> you could either use geotools or gdal with python to do that real
> quickly.
> >>
> >> Simone.
> >> -------------------------------------------------------
> >> Ing. Simone Giannecchini
> >> GeoSolutions S.A.S.
> >> Owner - Software Engineer
> >> Via Carignoni 51
> >> 55041  Camaiore (LU)
> >> Italy
> >>
> >> phone: +39 0584983027
> >> fax:      +39 0584983027
> >> mob:    +39 333 8128928
> >>
> >>
> >> http://www.geo-solutions.it
> >> http://simboss.blogspot.com/
> >> http://www.linkedin.com/in/simonegiannecchini
> >>
> >> -------------------------------------------------------
> >>
> >>
> >>
> >> On Wed, May 27, 2009 at 3:49 PM, Martin Tomko <[email protected]>
> >> wrote:
> >>
> >>>
> >>> Dear all,
> >>> would anyone know of a simple tool creating individual world files for
> >>> shapefile -indexed raster tiles? Or do I have to hack it myself?
> >>> cheers
> >>> Martin
> >>>
> >>> _______________________________________________
> >>> Geowanking mailing list
> >>> [email protected]
> >>> http://geowanking.org/mailman/listinfo/geowanking_geowanking.org
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >
> >
> >
> >
>
> _______________________________________________
> Geowanking mailing list
> [email protected]
> http://geowanking.org/mailman/listinfo/geowanking_geowanking.org
>
_______________________________________________
Geowanking mailing list
[email protected]
http://geowanking.org/mailman/listinfo/geowanking_geowanking.org

Reply via email to