2

I have a tiff image and got the world file which contains the needed information for GeoReferenceing,

how to start add this image on Mapserver ? if I use C# and use GMAP API to call the google server through internet to show map.

how to add this map with correct coordinate on it ? if I have to replace this API to have a local map server to use, it is ok as long as I still can use the new mapserver and API with C# windows application.

any suggestion? I have many times add similar to this question but all people answer to use GDAL, but I think GDAL to get the needed information which is already having them in the world file ?

1

If you are not familiar with Web servers I suggest you to use http://www.maptiler.org/

It is a really easy to use tool to generate tiles for Google Maps from any raster file. It will give you a Google Maps application at the end with your tiles on it. Note that it is against the licence to access the Google Maps API via C#.

If that's not what you want and simply want to display your raster file on top of another data source via C#, you must choose something else than Google Maps.

Edit:

From your comments, it seems that you prefer to use C# than Google Maps. In that case, there 2 things you can do.

The first is to use the GDAL API. It's not C#, but C++. If you can live with that, go for this option: http://www.gdal.org/gdal_tutorial.html

Second option is to use MapServer C# MapScript. This will probably do exactly what you want, but the documentation is a bit old and it will be harder to get help: http://www.paolocorti.net/2006/09/20/mapserver-tutorial-for-c-mapscript-asp-net/

One thing that is missing in the MapServer C# MapScript documentation is how to configure your georeferenced image in the mapfile (MapServer configuration file) Go here for the documentation.

With both option (GDAL C++ API or C# MapScript), start by simply displaying your georeferenced image without any other map under it. Once you will get that working, add a second raster layer (under the first one) using this documentation: http://www.gdal.org/frmt_wms.html

In the Example section of the above link, you will see several options to include: GoogleMaps, VirtualEarth, BlueMarble, OpenStreetMap, etc. Choose the one that you prefer and go for it.

  • why can't do via C#? is there any maps providers rather than Google to use with C#? – H.H Oct 31 '13 at 8:20
1

Answering the comment about the world file, the world file doesn't explicitly say which projection is being used by the tiff, though it does encapsulate the information. So yes you can directly use the world file information, or you can run gdalinfo and it should provide the projection information for you, it's just a convenience.

For more information on using the ESRI world file information see for example: World files for raster datasets

For example I have a world file that provides this information:

0.01000000000000
0.00000000000000
0.00000000000000
-0.01000000000000
-179.99500000000000
89.99500000000001

If I run gdalinfo with the proj4 option on the tif it comes with I get:

gdalinfo -proj4 my.tif
Driver: GTiff/GeoTIFF
Files: my.tif
       my.tfw
       amy.tif.aux.xml
Size is 36000, 9000
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
    PROJ.4 string is:
    '+proj=longlat +datum=WGS84 +no_defs '
Origin = (-180.000000000000000,90.000000000000000)
Pixel Size = (0.010000000000000,-0.010000000000000)
Metadata:
  AREA_OR_POINT=Area
  TIFFTAG_XRESOLUTION=1
  TIFFTAG_YRESOLUTION=1
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left  (-180.0000000,  90.0000000) (180d 0' 0.00"W, 90d 0' 0.00"N)
Lower Left  (-180.0000000,   0.0000000) (180d 0' 0.00"W,  0d 0' 0.01"N)
Upper Right ( 180.0000000,  90.0000000) (180d 0' 0.00"E, 90d 0' 0.00"N)
Lower Right ( 180.0000000,   0.0000000) (180d 0' 0.00"E,  0d 0' 0.01"N)
Center      (   0.0000000,  45.0000000) (  0d 0' 0.01"E, 45d 0' 0.00"N)

On the general question of serving a tiff from MapServer, you will need to create a map file which holds all the configuration details. With regards the spatial (as opposed to supporting metadata) information in particular you will need to have in your map file, you will need to have:

MAP
    ...
        #Units of the map coordinates
    UNITS dd
        #The extent of the service in the coordinates of the service default projection
    EXTENT -180.0000 30.0000 180.0000 90.0000
    PROJECTION
            # The default projection of the service
            # This can be anything you like
       "init=epsg:4326"
    END
    WEB
        ...
        METADATA
               # The projections you want the service to support
           "OWS_SRS" "EPSG:3411 EPSG:3413 EPSG:3857 EPSG:4326"
        ...
    END
    END
    LAYER
    TYPE RASTER
            # The extent of the layer data in the coordinates of the native projection
    EXTENT -180.0000 30.0000 180.0000 90.0000
    PROJECTION
                #The projection the data is actually in
            "proj=longlat"
                "ellps=WGS84"
                "datum=WGS84"
                "no_defs"
    END
    METADATA
                # The projections you want the individual layer to support
                # Can be omitted if using the same as the service
        "OWS_SRS" "EPSG:3411 EPSG:3413 EPSG:3857 EPSG:4326"
                ...
           END
     END
END

MapServer relies on the Proj.4 library for projections, which can be specified using a short cut looking for a file (epsg) like "init=epsg:4326" that holds the proj4 information, or inline as in the second (layer) projection information above. So if you are writing the map file dynamically (using C# etc) you will need to calculate this proj4 information from your world file, or from the gdalinfo output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.