# [Proj] Projecting a rectangle to another coord. system?

Glynn Clements glynn.clements at virgin.net
Mon Sep 13 16:15:07 EDT 2004

```Mikael Rittri wrote:

> G> It's the reverse case which doesn't work. If you project a
> G> rectangle which encloses the pole, the north and south edges
> G> of the bounding box will be determined by the min/max
> G> latitudes of the border points; the projection of the pole
> G> will lie above or below the bounding box of the projected border.
>
> But we would need the reverse case as well, because of "demand-driven
> geodata access" (or whatever it should be called).  When the user looks
> at a polar projection, the zoom level etc. of his window determines a
> bounding rectangle which is defined in the polar projection.  The
> geodata, on the other hand, are defined in lat/lon in a database,
> which can be queried with a bounding lat/lon-rectangle.  That is,
> the database returns only the polygons that intersect the lat/lon-
> rectangle of interest.  So we need to find a lat/lon-rectangle which
> covers at least the polar rectangle --- that's the reverse case.
>
> Since I thought all GIS systems behave like this, I hoped the
> fully general problem (including discontinuities) had been solved
> (and published).

I doubt it. Actually, I'm not sure that it's possible to derive a
mechanism which will work in the general case.

Also, you might do better asking in a forum which is concerned with
numerical methods generally. Essentially, you're looking for a
numerical method to compute the minima and maxima of f(x,y) for
arbitrary f where x and y are bounded. In that sense, the fact that f

OTOH, if you had an algebraic representation of the projection
function, you could (potentially) determine the maxima and minima
analytically. However, you can't realistically get this information
out of PROJ.

[I have examined the possibility of parsing the PROJ source code, but
it's just too messy, in the sense that it depends too heavily on
imperative constructs.]

I suspect that the most feasible approach is to specify a function to
compute the bounding box on a per-projection basis. Most projections
could use a generic algorithm based upon adaptive sampling, while a
few would need to handle special cases explicitly, using a
manually-derived analytical solution.

--
Glynn Clements <glynn.clements at virgin.net>

```