domlysz / BlenderGIS

Blender addons to make the bridge between Blender and geographic data
GNU General Public License v3.0
7.79k stars 1.36k forks source link

Geodata basemaps not matching with external .shp files in the same coordinate system #763

Open markus-ifg opened 1 year ago

markus-ifg commented 1 year ago

Blender and OS versions

Blender 3.4, Windows 10

Describe the bug

Geodata basemaps appear to be distorted, so that external .shp files in the same coordinate system do not overlap correctly.

How to Reproduce

Here is a map of cologne in QGIS, where as an example I traced a reference curve along the bridges. Coordinate system is EPSG:25832 (ETRS89, UTM zone 32N). image

When I use Blendergis to zoom into the same area, convert to the same coordinate system and then import the shapefile of my traced polyline in that coordinate, it obviously does not align with the river: image

I tried to follow the documentation as close as possible, but unless I'm missing a vital step it appears that the imported maps have a significant deviation in coordinates, even though they display correctly in QGIS with the same coordinate setting. :(

Error message

There is no error message.

momentmal commented 1 year ago

@markus-ifg I had a similar problem, I could not get shapefiles to project correctly onto my terrain although the shapefiles were saved correctly in the same CRS.

However, when I just saved the shapefiles in epsg3857 wgs84 projection and specified the shapefile CRS to be webmercator, Blender GIS was able to correctly reproject the shapefiles into my scene CRS.

domlysz commented 6 months ago

swiching the crs of the scene does note reproject existing meshes, it update only the coordinate of the scene origin for subsequent data import.

Maybee the doc is not clear enough about this https://github.com/domlysz/BlenderGIS/wiki/Shapefile-import#reprojection-capabilities

markus-ifg commented 6 months ago

Hi @domlysz, thanks for replying. I had feared that the addon is abandonend. ;)

To your answer: As I wrote and as also @momentmal confirmed, I was not expecting BlenderGIS to reproject my mesh. I simply selected an area in BlenderGIS in the default coordinate System (lets call it "A") and converted to another coordinate system "B". Then I import a shapefile which already is in coordinate system "B", but it does not match up as it should.

domlysz commented 6 months ago

Yes that's what I says, there is no mesh reprojection with this workflow so it will never match

For example : if you start the basemap tool to grab some aerial photography then your coordinate system will be set to Web Mercator and the scene origin will be set to the coordinates in Web Mercator of your location of interest. Cologne for example : x = 774446 y = 6610016

Sans titre

If the plane mesh measure 10x8km and it's origin match the scene origin then the top left corner will be x = 774446 - (10000/2) = 769446 y = 6610016 + (8000/2) = 6614016

Then you switch the scene CRS to EPSG:25832, the coordinates of the origin become 356451, 5644718, but your plane mesh is still 10x8km (there is no reprojection and the web mercator projection has more distortions than a local UTM projection). So, in Blender your top left corner will be x = 356451 - (10000/2) = 351451 y = 5644718 + (8000/2) = 5648718

But this coordinate is wrong, you can easily check this by reprojecting to original top left corner in web mercator in epsg.io

image

In this example it should be x=353366 y=5647323, the deltas are about 2km on x and 1.4km on y

In summary :

momentmal commented 6 months ago

maybe I'm missing something (this thread is ancient and I haven't touched the plugin for a long time), but i don't know why you keep bringing up an example of switching the CRS, when we both stated we made sure both our scene CRS and the imported .shp file were already in the same CRS..

For context / understanding: From what i remember, what I was testing, was importing a .shp file after having done reprojection in either blender GIS or Blender OSM of my terrain, which is a feature that is working if you have the needed python plugin installed. But its too long ago to precisely recall my workflow.

if i actually mixed those two plugins (can't remember), maybe its some stuff those 2 plugins are handling differently.

if not, maybe i really expected blender GIS to reproject, but it wasn't.

either way, thanks for the explanations!

markus-ifg commented 6 months ago

I guess he is saying that the initial base mesh from the basemap tool is always in Web Mercator and does not transform right (e.g. only the center point). I also haven't used it in a while, but I guess there is no option to specify the CRS right at the start when creating the basemap. Eventually I created the basemap texture and DEM data separately already in the right coordinate system, then it works. But it would be cool to be able to use the basemap tool directly.

domlysz commented 6 months ago

I guess he is saying that the initial base mesh from the basemap tool is always in Web Mercator and does not transform right (e.g. only the center point).

That's it and I admit it's confusing

I guess there is no option to specify the CRS right at the start when creating the basemap.

Only if GDAL is installed but it's a pain to install it with Blender Python setup

But it would be cool to be able to use the basemap tool directly.

I know this addon need a big refactoring