locationtech-labs / geopyspark

GeoTrellis for PySpark
Other
179 stars 59 forks source link

has mosaics in overlapping areas #684

Open mingnet opened 6 years ago

mingnet commented 6 years ago

When two tiff images overlap, the sliced data has mosaics in overlapping areas. The overlap area of two tiff images may be different because of different shooting times. The system seems to randomly take data from two tiff images.

I ingest the data like this.

    tiflist = [os.path.join(basepath, b) for b in filelist]
    raster_layer = gps.geotiff.get(layer_type=gps.LayerType.SPATIAL, uri=tiflist,num_partitions=100)
    raster_layer.persist(pyspark.StorageLevel.MEMORY_AND_DISK_SER)
    tiled_layer = raster_layer.tile_to_layout(layout=gps.GlobalLayout(), target_crs=3857)
    pyramid = tiled_layer.pyramid()
    for layer in pyramid.levels.values():
        gps.write(destpath, key, layer, time_unit=gps.TimeUnit.DAYS)

what should I do?

jbouffard commented 6 years ago

Hello, @mingnet! Let me first apologize for taking so long to respond to your issue. I had to do work on other projects which kept me from GPS :slightly_frowning_face:

To make sure that I'm understanding correctly: you have images that were taken at different times that cover the same area. You want the data that was taken at different times to segregated by that time when saving the layer. Is that correct?

If so, I think I see your issue.

raster_layer = gps.geotiff.get(layer_type=gps.LayerType.SPATIAL, uri=tiflist,num_partitions=100)

The line above reads in the data as a SPATIAL layer. However, this is not what you'd want as it only takes space into consideration but not time. Instead, you'd want to read it in as a SPACETIME layer. This will make it so that each raster your read in with be indexed by both the area it covers and the time the data was taken. I believe that if you read in the layer as SPACETIME all of your issues should be resolved.

mingnet commented 6 years ago

Anyway, thank you very much. This may be a solution. Let me try to do this.

jbouffard commented 6 years ago

@mingnet Don't mention it! I hope that it works.