Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to Georeference Google Tiles #400

Open
nc3d opened this issue Oct 6, 2023 · 10 comments
Open

How to Georeference Google Tiles #400

nc3d opened this issue Oct 6, 2023 · 10 comments

Comments

@nc3d
Copy link

nc3d commented Oct 6, 2023

Hi,
I need to georeference the Google tiles. I want to use a GIS package (Global Mapper) to reproject the data to a state plane coordinate system. What is the relationship between the coordinates of the imported geometry in Blender to WGS 84 or another coordinate system?
Thanks very much!
-Donald Newlands

@vvoovv
Copy link
Owner

vvoovv commented Oct 7, 2023

Hi @nc3d

Coordinates in Google 3D Tiles are in meters with the origin at the center of the planet Earth. That means millions of meters for each axes. The addon performs some geometrical transformation to bring the 3D Tiles for the requested area to the center of Blender's system of origin.

@nc3d
Copy link
Author

nc3d commented Oct 9, 2023

If we knew the translation applied to the WGS coordinates then we could accurately reproject the data into a known coordinate system. Our projects are typically in a planar state plane coordinate system that we translate (move) so that the origin (0,0) is close to the center of the model to reduce rounding errors. Because the model is tied to a known coordinate system, we can import and combine data from GIS systems and civil engineering. I assume that the Google 3D tiles are based on WGS 84 because that's what Google's Java API uses. If we also knew the translation from WGS for each import, we could move or reproject the Blosm data to mesh with other data.

Is there a way to find the translation that Blosm applies to the imported data?

Thanks very much!

-Donald

@vvoovv
Copy link
Owner

vvoovv commented Oct 9, 2023

The transformations are performed in the module blosm/release/threed_tiles/blender.py starting from the line 34.

The goal is to bring the area of interest to the center of origin with the center of the area of interest point strictly upwards (along Z-axis).

For that we apply the rotations:

  1. around Z-axis,
  2. around X-axis.

That brings the area of interest to the north pole.

Then we move the area of interest downwards to the origin.

@psucivengr
Copy link

@nc3d , did you ever figure this out? I'm also a Global Mapper user and I think I'm trying to do the same things you mention above. I have been trying for a while to understand how BLOSM reprojects things so I can bring in my own elements and create things at scale. I've tried using WGS, UTM, and State Plane but can't get the conversions to work out. My 1km x 1km test plane doesn't even seem to come in at the correct size/scale.

@nc3d
Copy link
Author

nc3d commented Oct 13, 2023

I don't think the code transforms the data to any known coordinate system. The python code could be modified to use the pyproj library to reproject the data to a state plane coordinate system with a transform value to move the origin to the center of the model. I might give this a try someday if I get another project where we'd need a lot of Google 3D tiles to accurately line up with our design and GIS data.

@pveierland
Copy link

Based on the documentation I've had success with the following approach:
https://github.com/vvoovv/blosm/wiki/Georeferenced-Blender-Scene

Computing the latitude / longitude of a selected object:

transverse_mercator_latitude = bpy.context.scene.get("lat")
transverse_mercator_longitude = bpy.context.scene.get("lon")

target_object = bpy.context.object

transformer = pyproj.Transformer.from_crs(
    pyproj.CRS.from_proj4(
        f"+proj=tmerc +lat_0={transverse_mercator_latitude} +lon_0={transverse_mercator_longitude}"
    ),
    pyproj.CRS.from_epsg(4326),
)

latitude_degrees, longitude_degrees = transformer.transform(
    target_object.matrix_world.translation[0],
    target_object.matrix_world.translation[1],
)

@vvoovv
Copy link
Owner

vvoovv commented Oct 20, 2023

@pveierland

How did you install pyproj in Blender's Python?

@pveierland
Copy link

I'm using a development shell via Nix that sets up my Python environment, then I just run Blender within that environment with a PYTHONPATH that includes the pyproj and other needed packages.

@psucivengr
Copy link

@nc3d - It's not using a known GCS but the data from different sources (terrain, imagery, 3d buildings) lines up in Blender so there has to be a pseudo-projection there, even if it's not a standard GCS.

I created a 1km x 1km square as a test area to try and reproduce the conversion from lat/long to BLOSM Projection and created a 'grid' using the GPX importer, looks like things mostly line up (within a meter or two):
image

@vvoovv - In which .py file is the GPX file converted to the Blender curve? I'm still trying to understand/replicate the conversion process. Are any attributes/properties from the calculation stored anywhere in the Blender file where I can find them and use them? I'm wondering if you have to store coordinates with the terrain object for the 'Relative to initial import' part to work. If I can figure out a reprojection for this, I'd be all kinds of happy!

@vvoovv
Copy link
Owner

vvoovv commented Oct 20, 2023

@psucivengr

The related code starts in the method render (line 34) of the module blosm.gpx, class GpxRenderer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants