DigitalGlobe / gbdxtools

(Deprecated) Python SDK for using GBDX
MIT License
74 stars 57 forks source link

TmsImage proj argument seems to be ignored #600

Closed duckontheweb closed 4 years ago

duckontheweb commented 5 years ago

GBDXTools New Issue

Please provide some background information:

GBDX Username

jon.duckworth@digitalglobe.com

GBDX Account Tier

Internal DG user

GBDXTools Version

Run pip show gbdxtools in a terminal or !pip show gbdxtools in a Jupyter notebook cell

Name: gbdxtools Version: 0.16.1 Summary: API wrapper and imagery access for the GBDX Platform Home-page: https://github.com/DigitalGlobe/gbdxtools Author: DigitalGlobe Author-email: UNKNOWN License: MIT Location: /anaconda/envs/gbdx_py3/lib/python3.6/site-packages Requires: toolz, pycurl, configparser, future, numpy, cloudpickle, mock, boto3, affine, pyproj, ephem, requests-futures, requests, shapely, pytest-runner, vcrpy, pytest, six, gbdx-auth, scikit-image, mercantile, cachetools, bumpversion, dask Required-by:

Python Version

Environment

[ If local, please provide more information about your local Python environment. For example, which Python executable - system or Anaconda? ]

Happens in conda environment and virtualenv environment.

Description

Using the proj argument when instantiating a TmsImage instance seems to have no effect. If I use proj='EPSG:4326' and save the image using the geotiff method it saves an image in the native EPSG:3857.

Expected behavior:

Image saved as EPSG:4326.

Actual behavior:

Image saved as EPSG:3857

Example

from gbdxtools import TmsImage
from os import environ
import rasterio

bbox = [-104.966, 39.711, -104.958, 39.719]
zoom_level = 16

tms = TmsImage(
    zoom=zoom_level, 
    bbox=bbox, 
    access_token=environ['MAPBOX_API_KEY'], 
    proj='EPSG:4326'
    # proj=4326 has same effect
)
tms.geotiff(path='/tmp/test.tif')

with rasterio.open('/tmp/test.tif') as src:
    print(src.crs)

# Prints '+init=epsg:3857'
chelm commented 5 years ago

Looked at this a bit and we're not currently sure if TMSImage ever actually support the proj param. Its proving to be a bit tricky to support it too. Will keep looking for a solution.

chelm commented 5 years ago

In the meantime i'd handle this via gdal_warp after its been converted to a tif, if thats helpful.

duckontheweb commented 5 years ago

Okay, no problem. We're currently using gdal_warp in our pipeline, so no rush on fixing this. It might be good to remove the proj argument from the docs just so no one runs into this until it is fixed.

chelm commented 5 years ago

@duckontheweb yeah good call. Will do that.

drwelby commented 4 years ago

With dask-based warping not working correctly, there's no available solution internal to GBDXtools.