Georeferencing a raster without worldfile

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Georeferencing a raster without worldfile

Trond Michelsen-3
Hi.

I'm using mapserver 7.0.0

I have about 250.000 raster images that I want to serve through
mapserver. They are all 1195x1550 pixels, and they all cover the exact
same area (UTM33N -75000,6450000,1120000,8000000).  All images has a
resolution of 1km per pixel.

I also have a worldfile that works:
--8<--
1000
0.0
0.0
-1000
-75000
8000000
--8<--

What I want to avoid, is to have one worldfile for each of the 250.000 files.

I have tried to use a processing directive, like the documentation says:

--8<--
WORLDFILE=<file>
    Specifies an alternative world file (for georeferencing). If a
    path only is specified, the base name of the dataset will be
    appended. The suffix (.wld / .tfw / ...) can be omitted.

    Example:

        PROCESSING "WORLDFILE=/path/"
         or
        PROCESSING "WORLDFILE=/path/file.wld"
         or
        PROCESSING "WORLDFILE=/path/file"
--8<--

But adding

PROCESSING "WORLDFILE=/path/to/my/worldfile.wld"

to my mapfile has, as far as I can tell, absolutely no effect.


The projection on the layer is defined like this:

  PROJECTION
    "+init=epsg:32633"
  END


If I change that to

  PROJECTION
    "+init=epsg:32633 +units=km"
  END

My layer will turn up at 0,0,1195000,1550000 in EPSG:32633

In theory, if I added easting and northing to the projection definition, like this:

  PROJECTION
    "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
  END

It should position itself properly, but proj does not allow easting or
northing to the UTM projections.

The documetation also states:

--8<--
wms_extent

    For Rasters served through WMS, MapServer can now use the
    wms_extent metadata parameter to register the image. If a .wld
    file cannot be found, MapServer will then look for the wms_extent
    metadata parameter and use the extents of the image and the size
    of the image for georegistration.
--8<--

However, if I add

  METADATA
    "wms_extent" "-75000 6450000 1120000 8000000"
  END

to the layer, it has no effect.


So... What am I doing wrong? How do I get my files to show up where
they're supposed to?


--
Trond Michelsen
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Georeferencing a raster without worldfile

Fawcett, David (MNIT)
If these are .tif files, can you write the georeference info to internal metadata as a way to avoid a .tfw file?

-----Original Message-----
From: mapserver-users [mailto:[hidden email]] On Behalf Of Trond Michelsen
Sent: Friday, December 01, 2017 10:19 AM
To: Mapserver <[hidden email]>
Subject: [mapserver-users] Georeferencing a raster without worldfile

Hi.

I'm using mapserver 7.0.0

I have about 250.000 raster images that I want to serve through mapserver. They are all 1195x1550 pixels, and they all cover the exact same area (UTM33N -75000,6450000,1120000,8000000).  All images has a resolution of 1km per pixel.

I also have a worldfile that works:
--8<--
1000
0.0
0.0
-1000
-75000
8000000
--8<--

What I want to avoid, is to have one worldfile for each of the 250.000 files.

I have tried to use a processing directive, like the documentation says:

--8<--
WORLDFILE=<file>
    Specifies an alternative world file (for georeferencing). If a
    path only is specified, the base name of the dataset will be
    appended. The suffix (.wld / .tfw / ...) can be omitted.

    Example:

        PROCESSING "WORLDFILE=/path/"
         or
        PROCESSING "WORLDFILE=/path/file.wld"
         or
        PROCESSING "WORLDFILE=/path/file"
--8<--

But adding

PROCESSING "WORLDFILE=/path/to/my/worldfile.wld"

to my mapfile has, as far as I can tell, absolutely no effect.


The projection on the layer is defined like this:

  PROJECTION
    "+init=epsg:32633"
  END


If I change that to

  PROJECTION
    "+init=epsg:32633 +units=km"
  END

My layer will turn up at 0,0,1195000,1550000 in EPSG:32633

In theory, if I added easting and northing to the projection definition, like this:

  PROJECTION
    "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
  END

It should position itself properly, but proj does not allow easting or northing to the UTM projections.

The documetation also states:

--8<--
wms_extent

    For Rasters served through WMS, MapServer can now use the
    wms_extent metadata parameter to register the image. If a .wld
    file cannot be found, MapServer will then look for the wms_extent
    metadata parameter and use the extents of the image and the size
    of the image for georegistration.
--8<--

However, if I add

  METADATA
    "wms_extent" "-75000 6450000 1120000 8000000"
  END

to the layer, it has no effect.


So... What am I doing wrong? How do I get my files to show up where they're supposed to?


--
Trond Michelsen
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Georeferencing a raster without worldfile

Trond Michelsen-3
Thank you for the suggestion. Unfortunately, I forgot to mention that
they're png-files.

--
Trond Michelsen


On Fri, Dec 01, 2017 at 04:38:38PM +0000, Fawcett, David (MNIT) wrote:

> If these are .tif files, can you write the georeference info to internal metadata as a way to avoid a .tfw file?
>
> -----Original Message-----
> From: mapserver-users [mailto:[hidden email]] On Behalf Of Trond Michelsen
> Sent: Friday, December 01, 2017 10:19 AM
> To: Mapserver <[hidden email]>
> Subject: [mapserver-users] Georeferencing a raster without worldfile
>
> Hi.
>
> I'm using mapserver 7.0.0
>
> I have about 250.000 raster images that I want to serve through mapserver. They are all 1195x1550 pixels, and they all cover the exact same area (UTM33N -75000,6450000,1120000,8000000).  All images has a resolution of 1km per pixel.
>
> I also have a worldfile that works:
> --8<--
> 1000
> 0.0
> 0.0
> -1000
> -75000
> 8000000
> --8<--
>
> What I want to avoid, is to have one worldfile for each of the 250.000 files.
>
> I have tried to use a processing directive, like the documentation says:
>
> --8<--
> WORLDFILE=<file>
>     Specifies an alternative world file (for georeferencing). If a
>     path only is specified, the base name of the dataset will be
>     appended. The suffix (.wld / .tfw / ...) can be omitted.
>
>     Example:
>
>         PROCESSING "WORLDFILE=/path/"
>          or
>         PROCESSING "WORLDFILE=/path/file.wld"
>          or
>         PROCESSING "WORLDFILE=/path/file"
> --8<--
>
> But adding
>
> PROCESSING "WORLDFILE=/path/to/my/worldfile.wld"
>
> to my mapfile has, as far as I can tell, absolutely no effect.
>
>
> The projection on the layer is defined like this:
>
>   PROJECTION
>     "+init=epsg:32633"
>   END
>
>
> If I change that to
>
>   PROJECTION
>     "+init=epsg:32633 +units=km"
>   END
>
> My layer will turn up at 0,0,1195000,1550000 in EPSG:32633
>
> In theory, if I added easting and northing to the projection definition, like this:
>
>   PROJECTION
>     "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
>   END
>
> It should position itself properly, but proj does not allow easting or northing to the UTM projections.
>
> The documetation also states:
>
> --8<--
> wms_extent
>
>     For Rasters served through WMS, MapServer can now use the
>     wms_extent metadata parameter to register the image. If a .wld
>     file cannot be found, MapServer will then look for the wms_extent
>     metadata parameter and use the extents of the image and the size
>     of the image for georegistration.
> --8<--
>
> However, if I add
>
>   METADATA
>     "wms_extent" "-75000 6450000 1120000 8000000"
>   END
>
> to the layer, it has no effect.
>
>
> So... What am I doing wrong? How do I get my files to show up where they're supposed to?
>
>
> --
> Trond Michelsen
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Georeferencing a raster without worldfile

rgreenwood


On Fri, Dec 1, 2017 at 9:50 AM, Trond Michelsen <[hidden email]> wrote:
Thank you for the suggestion. Unfortunately, I forgot to mention that
they're png-files.

--
Trond Michelsen


On Fri, Dec 01, 2017 at 04:38:38PM +0000, Fawcett, David (MNIT) wrote:
> If these are .tif files, can you write the georeference info to internal metadata as a way to avoid a .tfw file?
>
> -----Original Message-----
> From: mapserver-users [mailto:[hidden email]] On Behalf Of Trond Michelsen
> Sent: Friday, December 01, 2017 10:19 AM
> To: Mapserver <[hidden email]>
> Subject: [mapserver-users] Georeferencing a raster without worldfile
>
> Hi.
>
> I'm using mapserver 7.0.0
>
> I have about 250.000 raster images that I want to serve through mapserver. They are all 1195x1550 pixels, and they all cover the exact same area (UTM33N -75000,6450000,1120000,8000000).  All images has a resolution of 1km per pixel.
>
> I also have a worldfile that works:
> --8<--
> 1000
> 0.0
> 0.0
> -1000
> -75000
> 8000000
> --8<--
>
> What I want to avoid, is to have one worldfile for each of the 250.000 files.
>
> I have tried to use a processing directive, like the documentation says:
>
> --8<--
> WORLDFILE=<file>
>     Specifies an alternative world file (for georeferencing). If a
>     path only is specified, the base name of the dataset will be
>     appended. The suffix (.wld / .tfw / ...) can be omitted.
>
>     Example:
>
>         PROCESSING "WORLDFILE=/path/"
>          or
>         PROCESSING "WORLDFILE=/path/file.wld"
>          or
>         PROCESSING "WORLDFILE=/path/file"
> --8<--
>
> But adding
>
> PROCESSING "WORLDFILE=/path/to/my/worldfile.wld"
>
> to my mapfile has, as far as I can tell, absolutely no effect.
>
>
> The projection on the layer is defined like this:
>
>   PROJECTION
>     "+init=epsg:32633"
>   END
>
>
> If I change that to
>
>   PROJECTION
>     "+init=epsg:32633 +units=km"
>   END
>
> My layer will turn up at 0,0,1195000,1550000 in EPSG:32633
>
> In theory, if I added easting and northing to the projection definition, like this:
>   PROJECTION
>     "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
>   END
>
> It should position itself properly, but proj does not allow easting or northing to the UTM projections.


You can specify the full proj style definition instead of the "init=epsg:xxxx" format. So maybe something like:

PROJECTION
  +proj=tmerc
  +lat_0=0.0
  +lon_0=15    # not sure this is correct long0 is for zone 33
  +x_0=-75000
  +y_0=6450000
  +a=6378137.0 
  +b=6356752.3141403 
  +datum=WGS84
  +units=km 
END 



> The documetation also states:
>
> --8<--
> wms_extent
>
>     For Rasters served through WMS, MapServer can now use the
>     wms_extent metadata parameter to register the image. If a .wld
>     file cannot be found, MapServer will then look for the wms_extent
>     metadata parameter and use the extents of the image and the size
>     of the image for georegistration.
> --8<--
>
> However, if I add
>
>   METADATA
>     "wms_extent" "-75000 6450000 1120000 8000000"
>   END
>
> to the layer, it has no effect.
>
>
> So... What am I doing wrong? How do I get my files to show up where they're supposed to?
>
>
> --
> Trond Michelsen
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



--
Richard W. Greenwood, PLS
www.greenwoodmap.com

_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Georeferencing a raster without worldfile

jratike80
In reply to this post by Trond Michelsen-3

Hi,

 

One alternative could be to read your png files through GDAL virtual raster http://www.gdal.org/gdal_vrttut.html

 

Problem that you should solve is how to inject the file name into the SourceFilename element

<SourceFilename relativeToVRT="1">utm.tif</SourceFilename>

 

But the wms_extent metadata seems quite promising to me. You could then change the file with %variable% in DATA. How did you test that it has no effect?

 

-Jukka Rahkonen-

 

Lähettäjä: mapserver-users [mailto:[hidden email]] Puolesta Richard Greenwood
Lähetetty: 1. joulukuuta 2017 19:56
Vastaanottaja: Trond Michelsen <trondmm-mapserver+[hidden email]>
Kopio: Mapserver <[hidden email]>
Aihe: Re: [mapserver-users] Georeferencing a raster without worldfile

 

 

 

On Fri, Dec 1, 2017 at 9:50 AM, Trond Michelsen <[hidden email]> wrote:

Thank you for the suggestion. Unfortunately, I forgot to mention that
they're png-files.

--
Trond Michelsen



On Fri, Dec 01, 2017 at 04:38:38PM +0000, Fawcett, David (MNIT) wrote:
> If these are .tif files, can you write the georeference info to internal metadata as a way to avoid a .tfw file?
>
> -----Original Message-----
> From: mapserver-users [mailto:[hidden email]] On Behalf Of Trond Michelsen
> Sent: Friday, December 01, 2017 10:19 AM
> To: Mapserver <[hidden email]>
> Subject: [mapserver-users] Georeferencing a raster without worldfile
>
> Hi.
>
> I'm using mapserver 7.0.0
>
> I have about 250.000 raster images that I want to serve through mapserver. They are all 1195x1550 pixels, and they all cover the exact same area (UTM33N -75000,6450000,1120000,8000000).  All images has a resolution of 1km per pixel.
>
> I also have a worldfile that works:
> --8<--
> 1000
> 0.0
> 0.0
> -1000
> -75000
> 8000000
> --8<--
>
> What I want to avoid, is to have one worldfile for each of the 250.000 files.
>
> I have tried to use a processing directive, like the documentation says:
>
> --8<--
> WORLDFILE=<file>
>     Specifies an alternative world file (for georeferencing). If a
>     path only is specified, the base name of the dataset will be
>     appended. The suffix (.wld / .tfw / ...) can be omitted.
>
>     Example:
>
>         PROCESSING "WORLDFILE=/path/"
>          or
>         PROCESSING "WORLDFILE=/path/file.wld"
>          or
>         PROCESSING "WORLDFILE=/path/file"
> --8<--
>
> But adding
>
> PROCESSING "WORLDFILE=/path/to/my/worldfile.wld"
>
> to my mapfile has, as far as I can tell, absolutely no effect.
>
>
> The projection on the layer is defined like this:
>
>   PROJECTION
>     "+init=epsg:32633"
>   END
>
>
> If I change that to
>
>   PROJECTION
>     "+init=epsg:32633 +units=km"
>   END
>
> My layer will turn up at 0,0,1195000,1550000 in EPSG:32633
>
> In theory, if I added easting and northing to the projection definition, like this:

>   PROJECTION
>     "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
>   END
>
> It should position itself properly, but proj does not allow easting or northing to the UTM projections.

 


You can specify the full proj style definition instead of the "init=epsg:xxxx" format. So maybe something like:

 

PROJECTION

  +proj=tmerc

  +lat_0=0.0

  +lon_0=15    # not sure this is correct long0 is for zone 33

  +x_0=-75000

  +y_0=6450000

  +a=6378137.0 

  +b=6356752.3141403 

  +datum=WGS84

  +units=km 

END 

 

 

 

> The documetation also states:
>
> --8<--
> wms_extent
>
>     For Rasters served through WMS, MapServer can now use the
>     wms_extent metadata parameter to register the image. If a .wld
>     file cannot be found, MapServer will then look for the wms_extent
>     metadata parameter and use the extents of the image and the size
>     of the image for georegistration.
> --8<--
>
> However, if I add
>
>   METADATA
>     "wms_extent" "-75000 6450000 1120000 8000000"
>   END
>
> to the layer, it has no effect.
>
>
> So... What am I doing wrong? How do I get my files to show up where they're supposed to?
>
>
> --
> Trond Michelsen
> _______________________________________________
> mapserver-users mailing list
> [hidden email]
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users



 

--

Richard W. Greenwood, PLS
www.greenwoodmap.com


_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users
Reply | Threaded
Open this post in threaded view
|

Re: Georeferencing a raster without worldfile

Trond Michelsen-3
In reply to this post by rgreenwood
On Fri, Dec 01, 2017 at 10:55:34AM -0700, Richard Greenwood wrote:

>>> In theory, if I added easting and northing to the projection definition,
>>> like this:
>>   PROJECTION
>>>     "+init=epsg:32633 +units=km +x_0=-75000 +y_0=6450000"
>>>   END
>>>
>>> It should position itself properly, but proj does not allow easting or
>> northing to the UTM projections.
> You can specify the full proj style definition instead of the
> "init=epsg:xxxx" format. So maybe something like:
>
> PROJECTION
>   +proj=tmerc
>   +lat_0=0.0
>   +lon_0=15    # not sure this is correct long0 is for zone 33
>   +x_0=-75000
>   +y_0=6450000
>   +a=6378137.0
>   +b=6356752.3141403
>   +datum=WGS84
>   +units=km
> END

Thanks! That did the trick. I had already tried "+proj=utm +zone=33
+ellps=WGS84 +datum=WGS84 +units=km +no_defs", without success, but

I just needed a couple of minor changes. First of all, my example I
got my signs mixed up, so easting/northing should be 75000 and
-6450000. I also had to add the shifting UTM33 uses, so the correct
easting is 575000. Finally, by adding the scale factor of 0.9996, the
image positioned itself exactly where I want it.

So, my final projection block is:

  PROJECTION
    +proj=tmerc
    +lat_0=0.0
    +lon_0=15
    +x_0=575000
    +y_0=-6450000
    +a=6378137.0
    +b=6356752.3141403
    +datum=WGS84
    +k_0=0.9996
    +units=km
  END


This is a workaround I can live with. Thank You.

--
Trond Michelsen
_______________________________________________
mapserver-users mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-users