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 Index Pyramid Tiles with Custom Encoding #3512

Open
KiktMa opened this issue Apr 17, 2023 · 3 comments
Open

How to Index Pyramid Tiles with Custom Encoding #3512

KiktMa opened this issue Apr 17, 2023 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@KiktMa
Copy link

KiktMa commented Apr 17, 2023

    Pyramid.upLevels(reprojected, tarlayoutScheme,startZoom, endZoom, Bilinear) { (rdd, z) =>
      val layerId = LayerId("layer_"+tableName, z)

      val tilesWithMetadata: RDD[(SpatialKey, Tile, TileLayerMetadata[String])] = rdd.map { case (key, tile) =>
        val topLeftCode = GeoSot.INSTANCE.getHexCode(rdd.metadata.extent.xmin, rdd.metadata.extent.ymax, 0, z)
        val bottomRightCode = GeoSot.INSTANCE.getHexCode(rdd.metadata.extent.xmax, rdd.metadata.extent.ymin, 0, z)
        val metaData = TileLayerMetadata(
          cellType = tile.cellType,
          layout = rdd.metadata.layout,
          extent = rdd.metadata.mapTransform(key),
          crs = rdd.metadata.crs,
          bounds = KeyBounds(topLeftCode, bottomRightCode)
        )
        (key, tile, metaData)
      }
      val indexKeyBounds: KeyBounds[SpatialKey] = {
        val KeyBounds(minKey, maxKey):KeyBounds[SpatialKey] = tilesWithMetadata.foreach((S) => S._1)
        KeyBounds(minKey, maxKey)
      }
      val keyIndex =
        ZCurveKeyIndexMethod.createIndex(indexKeyBounds)

      if (attributeStore.layerExists(layerId)) {
        AccumuloLayerDeleter(attributeStore).delete(layerId)
      }
      writer.write(layerId, rdd, keyIndex)
    }

Can someone help me solve this? I customized a tile encoding method, which obtains a string encoding based on the position information and hierarchy of each tile. I wanted to use this encoding to replace the encoding of the Z curve, but I reported an error during compilation,

[ERROR] D:\JavaConsist\Project\geotrellis-cuts\src\main\scala\com\spark\demo\index\SelfIndex.scala:113: type mismatch;
found : Unit
required: geotrellis.spark.KeyBounds[geotrellis.spark.SpatialKey]
[ERROR] val KeyBounds(minKey, maxKey):KeyBounds[SpatialKey] = tilesWithMetadata.foreach((S) => S._ 1)
[ERROR] ^
[WARNING] one warning found
[ERROR] one error found

May I ask how to apply custom encoding to the pyramid model

@KiktMa KiktMa changed the title is:open label:"help wanted" How to Index Pyramid Tiles with Custom Encoding is:open label:"help wanted" Apr 17, 2023
@pomadchin pomadchin added the question Further information is requested label May 27, 2023
@pomadchin
Copy link
Member

Hey @KiktMa, sry got a bit busy and didn't pay attention much to the incoming issues, I'll look into the question asap!

@pomadchin pomadchin self-assigned this May 27, 2023
@pomadchin
Copy link
Member

pomadchin commented May 27, 2023

Hmm, it is possible in this case to define a custom KeyIndexMethod and KeyIndex it wont be even neccessary writing a new code, all functions are generic enough to work with any KeyIndexMethod and KeyIndex definitions.

Could you descirbe on a bit more higher level, what's the idea behind these operations?

@KiktMa
Copy link
Author

KiktMa commented May 29, 2023

@pomadchin thank you for your reply
I now need to use a geosot encoding to encode the grid. I already have a method to implement this encoding, but it needs to obtain the encoding based on any latitude and longitude of the grid and its level. Do I need to obtain latitude and longitude information based on SpatialKey (x, y)? How should I calculate it. I have another question to ask you. I am currently using writer. write(layerId, rdd, ZCurveKeyIndexMethod) to write tiles into Accumulo. Is it possible to store them in Accumulo and encode them as Z-curves? The rowid is like this \x00\x00\x00\x00\x00\x1E"\xCB, but I am a bit confused about what this is? If it is, I should also store them in rowid using geosot encoding.Finally, if I want to build tiles with a resolution of 0.5 meters at level 18, how can I do it? I use ZoomedLayoutScheme to build a pyramid with a resolution of around 0.29 meters at level 18.
Sorry for raising so many questions. I hope you can reply when you have time. Thank you again

@pomadchin pomadchin changed the title How to Index Pyramid Tiles with Custom Encoding is:open label:"help wanted" How to Index Pyramid Tiles with Custom Encoding Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants