mapbox / robosat

Semantic segmentation on aerial and satellite imagery. Extracts features such as: buildings, parking lots, roads, water, clouds
MIT License
2.02k stars 382 forks source link

download from Mapbox endpoint pulls .webp files #145

Closed CooperNederhood closed 5 years ago

CooperNederhood commented 5 years ago

Hello, I have been working through your diary example on Tanzania but I want to pull from Mapbox instead as that is closer to what I'll ultimately be doing. I ran the command:

rs download https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.webp?access_token=[API_KEY] output_folder_name

But I get back .webp files rather than .png files. I am less experienced with Mapbox/OSM and I'm coming from a deep learning background so I'd prefer to work directly with png (or jpeg) files so I can try some different segmentation models outside of what is available in Robosat (and potentially try to build out some features in the process). Can I change my rs download line in some way to get png/jpeg?

Thanks for building such a great product!

jqtrde commented 5 years ago

Hi @CooperNederhood - check out the "Retrieve Tiles" documentation for details on how to pull different tile formats.

Gonna close here, but please reopen if ^ doesn't answer your question.

CooperNederhood commented 5 years ago

Thanks for the link, that was good information to know. However, when I changed my command to: rs download https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.png?access_token=[API_KEY] output_folder_name

I still was pulling .webp files. However, when I added the --ext option and ran the below command, I receive png files. I seem to be getting the output I wanted, but just wanted to point this out rs download --ext png https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}@2x.png?access_token=[API_KEY] output_folder_name

daniel-j-h commented 5 years ago

The .webp URl results in Mapbox sending a webp image file over the wire.

The --ext extension flag results in us saving the image file in the specified format.

We provide the ext flag so we not tied to tile endpoint formats.

radoslawkrolikowski commented 4 years ago

Hello. I am not sure if that changed during last year, but the current version of Mapbox Raster API Documentation says that "Tiles that include mapbox.satellite are always delivered as JPEGs, even if the URL specifies PNG". That can be proven by using gdalinfo example_raster.png that will return:

Driver: JPEG/JPEG JFIF
Files: example_raster.png
Size is 512, 512
Image Structure Metadata:
  COMPRESSION=JPEG
  INTERLEAVE=PIXEL
  SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)
Band 1 Block=512x1 Type=Byte, ColorInterp=Red
  Overviews: 256x256, 128x128
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 2 Block=512x1 Type=Byte, ColorInterp=Green
  Overviews: 256x256, 128x128
  Image Structure Metadata:
    COMPRESSION=JPEG
Band 3 Block=512x1 Type=Byte, ColorInterp=Blue
  Overviews: 256x256, 128x128
  Image Structure Metadata:
    COMPRESSION=JPEG

Moreover, as we can see this image is not geo-referenced (any info about CRS). The same is shown by rasterio crs which returns None. Could anyone please confirm that Mapbox Raster API doesn't return geo-referenced images anymore?

daniel-j-h commented 4 years ago

Slippy Map tiles are geo-referenced by means of their tile ids, i.e. z,x,y in /z/x/y.png. Please reads e.g. the OSM wiki docs on that.

Re. the Mapbox API I don't know if they have changed anything but in the past it was possible to download webp image tiles.

Good luck.

On June 7, 2020 8:22:37 AM UTC, radoslawkrolikowski notifications@github.com wrote:

Hello. I am not sure if that changed during last year, but the current version of Mapbox Raster API Documentation says that "Tiles that include mapbox.satellite are always delivered as JPEGs, even if the URL specifies PNG". That can be proven by using gdalinfo example_raster.png that will return:

Driver: JPEG/JPEG JFIF
Files: example_raster.png
Size is 512, 512
Image Structure Metadata:
 COMPRESSION=JPEG
 INTERLEAVE=PIXEL
 SOURCE_COLOR_SPACE=YCbCr
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)
Band 1 Block=512x1 Type=Byte, ColorInterp=Red
 Overviews: 256x256, 128x128
 Image Structure Metadata:
   COMPRESSION=JPEG
Band 2 Block=512x1 Type=Byte, ColorInterp=Green
 Overviews: 256x256, 128x128
 Image Structure Metadata:
   COMPRESSION=JPEG
Band 3 Block=512x1 Type=Byte, ColorInterp=Blue
 Overviews: 256x256, 128x128
 Image Structure Metadata:
   COMPRESSION=JPEG

Moreover, as we can see this image is not geo-referenced (any info about CRS). The same is shown by rasterio crs which returns None. Could anyone please confirm that API returns not geo-referenced rasters?