Archive for July, 2015

How to create a World File

In continuing effort of my last blog post, I will explain how you can create a simple world file to use with an image which is not georeferenced to use with AutoCAD MAP, Civil 3D and/or InfraWorks.

In my previous blog post “How to grab aerial images from WMS server” you have made a rectangle (or square) as the boundary to your project of where you want to download an aerial image from a WMS server.

Now I will use the same example to write down the coordinates of the upper left corner of that rectangle (or square). Now use the half of the value of the factor I have calculated back then (which is in fact the ground resolution of that particular image) and add this value to the X ordinate, and subtract the same value from the Y ordinate. The result will be used as the coordinates for the World File which in return will be used as the insertion point of the aerial image map.

Now create a text file with the following content (6 rules):

[calculated factor]
-[calculated factor]
X (value = UpperLeft X ordinate plus half the value of the calculated factor)
Y (value = UpperLeft Y ordinate minus half the value of the calculated factor)

If I use the same URL example from my previous blog,,375465.3687,209670.623,375965.3687&WIDTH=2000&HEIGHT=1000

the content of my World File will be as follows:


Save the file with the same name as the image you have downloaded from the WMS server but with the file extension built as follows:

If your image has the jpg file extension, use jgw as the file extension for the World File.  You can name any bitmap file extension by omitting the 2nd (or middle) character and by shifting the 3rd (or last) character to the left and finally by adding the ‘w’ character to the end. So ecw would become eww and png  would become pgw, etc.

You can also download the file here.

Now you can use both files, the downloaded aerial image with the self made World File in AutoCAD Map / Civil 3D or InfraWorks. You may even use these files in vanilla AutoCAD if you like, by using this free available tool: GeoRefInsert from the Autodesk Exchange Apps store. 

In my next blog post I will explain how you can successfully use a GDAL WMS XML file to use with InfraWorks.

Happy georeferencing! 😃 

July 25, 2015 at 10:58 am Leave a comment

How to grab aerial maps from WMS server

With AutoCAD Map 3D or AutoCAD Civil 3D (planning and Analysis workspace) you can connect to a WMS data server via the MAPCONNECT command. Once connected you can select a Layer or layers from the available presented list of layers, choose the coordinate system corresponding to the one you have set in your drawing and add the data to your drawing. If everything runs well your window screen will be filled with all the layer data from the selected WMS server.  Aerial Imagery maps can be served this way. Once you’ve connected and add aerial images to your map, your window will fill with aerial images. But you will not recoginize much detail. But by zooming in, much more detail will become available until a maximum value is reached. This maximum value is explained as ground resolution and stands for the image content expressed in a distance in units per pixel image.  For example: 0.5m/pixel or 50cm per pixel. The smaller the units expressed in cm or m (or inches/feet) the better the quality of the image.

However, you can not grab the image directly in AutoCAD Map 3D or Civil 3D to use as a standalone or as an attached image.  For this you could make a printscreen of your AutoCAD Window. But the resolution is as ‘good’ as your resolution of your screen. You could also use the re-sample function from the MapWorkspace to download the active screen to a temporary folder on disk. In both cases the retrieved imagery is not georeferenced and therefor hard to insert at the right coordinates back into the drawing.
Another and much better way is, to use the EXPORTMAPTODWG function, which will allow you to create a new DWG with the image attached to that DWG. But only the image of what you visual have zoomed into at that moment will be captured, created and attached. This way you have the retrieved image positioned at the right coordinates in the drawing. But the image resolution is as good as the resolution from screen.

There is an alternative way to do both: get a better image resolution and have the image georeferenced. How to grab an aerial image map from a WMS server, right after the jump.  Grabbing an aerial image map from a WMS server can be done via a web browser by using a typical URL with special parameters which the WMS server understands for retrieving the requested data from the server. But before you built this URL, you need to know which required parameters the wms server is using. This can be done by using the GetCapabilities request first. An example is given below:

This will return an XML file which can be opened in any text or XML editor.

In the next section I will explain which of the parameters can be used to built the GetMap request URL. The GetMap request URL can have or should contain the following parameters:

  1. Built the URL starting with the same WMS url you have used with the MAPCONNECT function in Map 3D or Civil 3D. Mostly it ends with a ? mark or & mark. What follows next does not have to be in a certain order. I.e
  2. Place the version=x.x.x phrase into the to be built URL. To know which version the wms server is using, request it by using the GetCapabilities first. I.e
  3. Place the REQUEST=GetMap phrase into the to be build URL like in the example below. Add the & character in front of the phrase. I.e.
  4. Place the LAYERS=layer name<,layer name> phrase. Add the & character in front of it. Use the same layer name(s) you have used in Map 3D/Civil 3D when connecting and adding the layer(s) to your Map. The right layer name(s) can be different than the display name(s) Map/Civil 3D will show you. If you want  the exact layer name(s), make use of the GetCapabilities request in an Internet browser before you continue. From that response you can filter out the right layer name(s). I.e.
  5. Determine the geographical or Projected coordinate system expressed as a EPSG code and place it into the URL as follows: SRS=EPSG:code or CRS=EPSG:code. Use CRS for 1.3 versions only. Replace the : character in the url with %3A. The required epsg code can also be found by using the GetCapabilities request first. I.e.
  6. Place the BBOX=LowerLeftX,LowerLeftY,UpperRightX,UpperRightY in the URL. And add the & character at the start. Define a window in Map3D/Cvil3D and determine the lower left and upper right coordinates. Draw a rectangle for example and write down the upper left and lower right coordinates. These coordinates will be used in the boundingbox (BBOX) part of the URL. I.e.,375465.3687,209670.623,375965.3687
  7. Place the FORMAT=image/jpeg phrase in the URL but replace the / with %2F so it will show image%2Fjpeg in the URL. Add the & character at the end. I.e.,375465.3687,209670.623,375965.3687&FORMAT=image%2Fjpeg
  8. Use the maximum allowed WIDTH and HEIGHT of the image grabbed from the WMS server. This could be different for every WMS server. Most of the times I found, sometimes by trial and error or sometimes by using the GetCapabilities request, the value of 2000 or 2048.
  9. Now here comes the trick: calculate the  width and height values of your  rectangle to the maximum WIDTH/HEIGHT so the width and height are in relation to each other. For instance: your largest side (width) of the rectangle is 1000m. Then your WIDTH value will be the maximum WIDTH of 2000. It needs a scale factor of 0.5 to get the 2000 into 1000m. Your shortest side (height) is 500m. Then your HEIGHT will be 1000 by using the same scale factor of 0.5. If you have drawn a rectangle with equal width and height, a square, you can use the same value for the maximum WIDTH/HEIGHT of the WMS server. This scale factor is also important for creating a World File later. I.e.,375465.3687,209670.623,375965.3687&FORMAT=image%2Fjpeg&WIDTH=2000&HEIGHT=1000

So the complete URL example of a WMS server GetMap request could look like this:,375465.3687,209670.623,375965.3687&WIDTH=2000&HEIGHT=1000

Applying the GetMap request URL into any webbrowser will result in showing the image within the given boundingbox. The below image is just for reference and will not have the same resolution as the image when you click the above URL.    Rightclick the image applied from the above URL and save it to your harddrive or network share. You now have the image ready to be used in AutoCAD.  But you are not there yet. This image example isn’t georeferenced. If the WMS server supports GeoTiff images, only then the saved image is geo referenced.

In my next post I will explain how to create a World File for non GeoTiff images like above example. Without using an application or add-on which can create World Files from images like Raster Design does.

Stay tuned.

July 18, 2015 at 2:17 pm 6 comments

Recent Posts

iPinda Tweets