Can't make imported OSM file and GeoTIFF match

2557
1
05-31-2014 01:48 AM
HoldenHk
New Contributor
Hello,
I'm new to CityEngine, and although I find the video tutorials quite informative, I encountered a problem immediately after I tried to do something just slightly different from the video. Let me describe what I did step-by-step:
1. I marked a relatively small area (in Taiwan) on OSM website end exported it (coordinates: N 23.3922, S 23.3834, W 120.4022, E 120.4187).
2. I used Global Mapper 15.0 to export a GeoTIFF of that location.
    - I chose ASTER GDEM as a source, and before I clicked CONNECT, I specified 'Latitude/Longitude Bounds of Area' by copying the coordinates above. If I don't do this Global Mapper downloads the whole world, and the navigation inside it is very inconvenient.
    - after pressing the CONNECT button, a blue relief map appears and I chose EXPORT > EXPORT ELEVATION GRID FORMAT from the FILE menu.
    - I select GeoTIFF, press OK, and Export Options pop up.
    - I check Elevation 32-bit
    - I check Generate TWF file
    - I check Generate PRJ file
    - I click on Export Bounds tab and key in Lat/Lon to make sure the coordinates match again, and a yellow frame appears on the blue relief map (the area I chose is, admittedly, quite featureless, but I tried this method with some more characteristic areas, and for sure the Global Mapper picks the right spot).
    - I press OK and save the files (GeoTIFF, TWF, and PRJ).
3. I start CityEngine, create a new project and copy the four files (OSM, GeoTIFF, TWF, and PRJ) to the maps directory within this project.
    - I drag the OSM map into the viewport, tick the elements I want (practically all, as this is countryside, so there are not many details anyway), check all the boxes in the Cleanup section the tutorial suggests, and confirm "WGS 1984 UTM Zone 51N" as Scene Coordinate System.
    - I can see the road grid and a few footprints, and it is the place I marked in OSM.
    - I drag the tif elevation file into the viewport. Its name appears in Heightmap and texture files in the dialogue box. I delete the texture file, so that the box is empty. I change the elevation to 500 (the highest point in the area does not exceed 100m though), press finish and the following pop-up appears "Error: Data is located too far from current scene's contents".

I understand what it means, i.e. the two files (osm and geotiff) are too far from each other etc., but I can't understand why the programs cannot read the geo reference from the osm and prj/twf files?

The listing of twf files is as follows:
/beginning of file/
0.00029296875000005
0
0
-0.00029296875
120.40219999999999
23.3922
/end of file/
The last two values agree with the ones provided in OSM website.

The listing of the prj file is here:
/beginning of file/
GEOGCS["GCS_WGS_1984",DATUM["D_WGS84",SPHEROID["WGS84",6378137,298.257223560493]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
/end of file/

The bounds in the osm file are as follows:
/beginning of file/
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.3.3 (29516 thorn-03.openstreetmap.org)" copyright="OpenStreetMap and contributors" attribution="http://www.openstreetmap.org/copyright" license="http://opendatacommons.org/licenses/odbl/1-0/">
<bounds minlat="23.3834000" minlon="120.4022000" maxlat="23.3922000" maxlon="120.4187000"/>
/end of file excerpt/

If I reverse the order of dragging the files, i.e. drag the elevation first, I am requested to manually select the Scene Coordinate System, and I choose WGS 1984 UTM Northern Hemisphere Zone 51 (Taiwan is in this zone and the same zone is suggested by CityEngine when dragging the osm file first). After dragging the osm file, the same pop-up appears.

I assume I might have done something wrong while exporting the elevation, since there are no options to choose from while exporting the OSM. What do I possibly do wrong and where?

Thanks in advance,

Holden
0 Kudos
1 Reply
HoldenHk
New Contributor
After digging a little bit, I found the source of the problem, which is a peculiar way of Global Mapper's transferring projection from the dialogue box to the actual file.
After numerous attempts (exporting different area sizes) I managed to make it work. I noticed that this time the GeoTIFF had already contained data on elevation and the area size - these things were previously set to default values (0-100 etc). I checked the prj and twf files, and it was immediately obvious the solution must be there, as the size of prj file was almost double than in the case of the unsuccessful attempt. Upon listing the file, everything became clear.

The old (failed) prj file looked like this:

/beginning of file/
GEOGCS["GCS_WGS_1984",DATUM["D_WGS84",SPHEROID["WGS84",6378137,298.257223560493]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
/end of file/

Whereas the new one contained much more information:

/beginning of file/
PROJCS["UTM_Zone_51_Northern_Hemisphere",GEOGCS["GCS_WGS_1984",DATUM["D_WGS84",SPHEROID["WGS84",6378137,298.257223560493]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",123],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1]]
/end of file/

The new twf file also contained different data from the old one.

The old file:
/beginning of file/
0.00029296875000005
0
0
-0.00029296875
120.40219999999999
23.3922
/end of file/

The new file:
/beginning of file/
32.613132068
0
0
-32.613132068
234468.58048
2589328.152
/end of file/

So far so good, but I still had no idea what happened, as I didn't do anything different than before. The only new thing I did was that I exported a bmp from MapQuest OSM server via Global Mapper (thinking that somehow things may align themselves, coming through the same machinery). Coincidentally, the BMP raster/image export also happens to offer prj and twf files, so I checked them (why not?). These files were the ones with the correct data.

However, to my frustration, I wasn't able to replicate the results, and I found an only slightly related video on youtube that suggested manual setting of projection in Global Mapper's setting. And there was the solution of the problem. The default projection setting in Global Mapper is 'Geographic (Latitude/Longitude)", which must be changed to UTM (the zone will adjust itself automatically). After this, all attempts of exporting different areas were successful.

I should have probably spent more time experimenting with exporting, yet the solution came by pure accident (how could I predict Global Mapper's unpredictable behavior while setting the projection?), and I might as well have missed it. Anyway, I hope it may save others a little time.
0 Kudos