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

[Question] How to use GeoJson-Tiler to create 3D objects from GeoJson #141

Open
stmaute opened this issue May 25, 2023 · 2 comments
Open

Comments

@stmaute
Copy link

stmaute commented May 25, 2023

Hello,

and first of all sorry for the newbie question.
But how can I generate 3D files (.b3dm) from a GeoJson file containing simple Polygon and LineString features.
I already tested the GeoJson Tiler with different options but none of them produced the expected outcome.
The width and height information are in the properties of the features. The altitude information of the LineString is the third coordinate. the height info for the Polygone is set in the properties.

So first question is it possible at all to achieve this?
If yes what would be the correct options to get it done?

This is the GeoJson I want to use to generate 3D tiles.

    {
      "type": "FeatureCollection",
      "features": [
        {
          "type": "Feature",
          "properties": {
            "width": 25
          },
          "geometry": {
            "coordinates": [
              [
                9.04383596292513,
                48.734186265768926,
                1000
              ],
              [
                9.051803790028401,
                48.730367500959886,
                1020
              ],
              [
                9.055806319998652,
                48.728672907914074,
                1025
              ],
              [
                9.06079552014819,
                48.727395785562635,
                1010
              ],
              [
                9.067422965122262,
                48.72624143553,
                1001
              ],
              [
                9.07021542789252,
                48.7254186379495,
                950
              ],
              [
                9.0724121652718,
                48.724264242532115,
                920
              ],
              [
                9.073938711586521,
                48.72328175747495,
                900
              ],
              [
                9.076321613150299,
                48.721758867706484,
                910
              ]
            ],
            "type": "LineString"
          }
        },
        {
          "type": "Feature",
          "properties": {
            "width": 25
          },
          "geometry": {
            "coordinates": [
              [
                9.085276110754904,
                48.72958158647924,
                900
              ],
              [
                9.08164590915365,
                48.72918863631139,
                880
              ],
              [
                9.078853446383476,
                48.729139517324654,
                875
              ],
              [
                9.076172682124195,
                48.72883252256935,
                870
              ],
              [
                9.073380219353936,
                48.7281325675192,
                850
              ],
              [
                9.069954798356491,
                48.72689227236256,
                800
              ],
              [
                9.065654405690708,
                48.72498878960545,
                800
              ],
              [
                9.062545463806856,
                48.723379983484165,
                810
              ],
              [
                9.059771617454771,
                48.7217588443452,
                790
              ],
              [
                9.056066950179968,
                48.71908139408606,
                780
              ]
            ],
            "type": "LineString"
          },
          "id": 1
        },
        {
          "type": "Feature",
          "properties": {
            "height": 50
          },
          "geometry": {
            "coordinates": [
              [
                [
                  9.079500266699029,
                  48.72882211256558
                ],
                [
                  9.074865930232164,
                  48.727411620084126
                ],
                [
                  9.073589455100091,
                  48.727475978017054
                ],
                [
                  9.072434936190973,
                  48.727068376384665
                ],
                [
                  9.072004024203494,
                  48.72658032271539
                ],
                [
                  9.072069067522108,
                  48.725722194888476
                ],
                [
                  9.073573194270665,
                  48.72438670433206
                ],
                [
                  9.07698796850886,
                  48.72554520420252
                ],
                [
                  9.076735925648677,
                  48.725931364896184
                ],
                [
                  9.0771749680504,
                  48.72611908082877
                ],
                [
                  9.07731318510281,
                  48.72636042885509
                ],
                [
                  9.07837013903449,
                  48.72671976710413
                ],
                [
                  9.078532747331451,
                  48.72733653572456
                ],
                [
                  9.079386440891255,
                  48.72766368818398
                ],
                [
                  9.079191310934448,
                  48.727947933673875
                ],
                [
                  9.079866135366984,
                  48.72818390984156
                ],
                [
                  9.079971830760513,
                  48.72843061101446
                ],
                [
                  9.079500266699029,
                  48.72882211256558
                ]
              ]
            ],
            "type": "Polygon"
          }
        }
      ]
    }

Would be really great if someone could help me with this?

Thanks in advance.

@LorenzoMarnat
Copy link
Collaborator

LorenzoMarnat commented May 30, 2023

Hello,

First I recommend not using degree projections (such as EPSG:4326) as input, since Py3DTilers doesn't handle those projections really well (see #135). You should export your data in a meter projection, such as EPSG:4978. Then, you can try to use the --crs_in/--crs_out Py3DTilers options to created 3DTiles with EPSG:4326 projection, but you may encounter placement or geometry issues.

Also, you should split your Polygons and LineStrings into different files, since they don't share the same properties.

Then, to create a 3D Tiles tileset from your LineStrings, run:

geojson-tiler -i .\test_lines_4978.geojson -o 3dtiles_lines --width width --height 5 --crs_in EPSG:4978 --crs_out EPSG:4326

--width width is to target the property called "width" as width. --height 5 will set the height of your features to 5 meters, you can use any other value (the value must be > 0 and must use a . for decimal numbers). Replace input (-i .\test_lines_4978.geojson) and output (-o 3dtiles_lines) with the names of your choice.

To create a 3D Tiles tileset from your Polygons, run:

geojson-tiler -i .\test_polygons_4978.geojson -o 3dtiles_polygons --height height --z 800 --crs_in EPSG:4978 --crs_out EPSG:4326

--height height is to target the property called "height" as height. --z 800 will set the altitude of your features to 800 meters, you can use any other value (the value must be > 0 and must use a . for decimal numbers). Replace input (-i .\test_polygons_4978.geojson) and output (-o 3dtiles_polygons) with the names of your choice.

If you still have misplaced 3D Tiles or strange geometries, it will surely be because of the --crs_out EPSG:4326. Sadly, there is no fix yet for this issue, the only solution is to use meter projections as input and output.

@stmaute
Copy link
Author

stmaute commented Jun 5, 2023

Hi @LorenzoMarnat,

thanks a lot for the answer. I tried to generate a 3D Tiles tileset with different CRS for the input and output but I didn't get it working. Either the 3D Tiles are correct and the geometries are broken or the other way round.

Do you know other tools or ways to create a tileset from geojson?
Is it planned that the Geojson-tiler supports degree projections?

Thanks in advance.

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

2 participants