GithubHelp home page GithubHelp logo

tuw-geo / equi7grid Goto Github PK

View Code? Open in Web Editor NEW
55.0 55.0 13.0 57.73 MB

Definition of the Equi7Grid - a spatial reference optimized for global high-resolution raster data.

License: MIT License

Python 98.10% Makefile 1.90%

equi7grid's Issues

Confusing results using search_tiles_in_roi and get_tile_bbox_proj

When searching tiles, it seems like we need to swap x and y to get the correct tile (We get AF instead of EU otherwise).
Further, when searching, we can specify CRS while the bbox for tiles is given in ?? metres??? or something ?

Is this a bug or should I use some other function to get the tile bbox in e.g EPSG:3006 ?

Output from the experiment with and without swapped x-y for EPSG3006 and EPSG4326:

 ??       left    lower     right   upper
             west,   south,    east,   north
            13.31,   59.09    14.11,   59.44
           403050, 6551299   449522  6589385
 -------  Non Swapped ---------------------
['AF300M_E096N066T6']
EPSG: 4326
ODC [[13.31, 59.09], [14.11, 59.44]]
EQ7 (9600000.0, 6600000.0, 10200000.0, 7200000.0)

['AF300M_E102N054T6']
EPSG: 3006
ODC [[403050.0, 6550350.0], [449550.0, 6590250.0]]
EQ7 (10200000.0, 5400000.0, 10800000.0, 6000000.0)

 -------   Swapped ---------------------
['EU300M_E048N024T6']
EPSG: 4326
ODC [[59.09, 13.31], [59.44, 14.11]]
EQ7 (4800000.0, 2400000.0, 5400000.0, 3000000.0)

['EU300M_E048N024T6']
EPSG: 3006
ODC [[6550350, 403050], [6590250, 449550]]
EQ7 (4800000.0, 2400000.0, 5400000.0, 3000000.0)

Cannot import Equi7Grid after pip install v0.2.3

Just leaving this here in case someone else tries to install the latest version of the package.
Looks like the data folder is not downloaded correctly in version 0.2.3.

I get the following error on import

>>> from equi7grid.equi7grid import Equi7grid
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/wpreimes/mambaforge/envs/io_utils/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 74, in <module>
    class Equi7Grid(TiledProjectionSystem):
  File "/home/wpreimes/mambaforge/envs/io_utils/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 95, in Equi7Grid
    _static_data = _load_static_data(__file__)
  File "/home/wpreimes/mambaforge/envs/io_utils/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 69, in _load_static_data
    with open(fname, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/wpreimes/mambaforge/envs/io_utils/lib/python3.9/site-packages/equi7grid/data/equi7grid.dat'

Workaround is to pip install equi7grid==0.2.2

However it should be easy to fix this. I assume something to do with the meta-package. Just let me know if you cannot work on this right now, I can take a look if you want.

The projection WKT files seem to be incomplete

I am working with the EQUI7 grid and the defined Azimuthal_Equidistant projection and seem to be unable to fully transform coordinates properly. I have traced the error back and found that it is unable to convert the file from WKT to PROJ4.

The following code works with input a) but not b). b) seems to be defined here in the project but is missing AXIS and AUTHORITY info from a).

from osgeo import osr

srs = osr.SpatialReference()
srs.ImportFromWkt(PROJ)
print(srs.ExportToProj4())

a)

PROJ = 'PROJCS["Azimuthal_Equidistant",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84", 6378137.0, 298.257223563, AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]],UNIT["degree", 0.017453292519943295],AXIS["Geodetic longitude", EAST],AXIS["Geodetic latitude", NORTH],AUTHORITY["EPSG","4326"]],PROJECTION["Azimuthal_Equidistant"],PARAMETER["longitude_of_center", 24.0],PARAMETER["latitude_of_center", 53.0],PARAMETER["false_easting", 5837287.81977],PARAMETER["false_northing", 2121415.69617],UNIT["m", 1.0],AXIS["Easting", EAST],AXIS["Northing", NORTH]]'

b)

PROJ = 'PROJCS["Azimuthal_Equidistant",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984", SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich ",0.0],UNIT["Degree",0.017453292519943295]],PROJECTION[" Azimuthal_Equidistant"],PARAMETER["false_easting",6988408.5356], PARAMETER["false_northing",7654884.53733],PARAMETER[" central_meridian",131.5],PARAMETER["latitude_of_origin",-19.5],UNIT ["Meter",1.0]]'

I get the following error with b)

ERROR 6: No translation for  Azimuthal_Equidistant to PROJ.4 format is known.

The original code is below that caused me the issue

from osgeo import osr

def get_geog_coords(geo_points, spatial_ref):
    t = osr.CoordinateTransformation(spatial_ref.CloneGeogCS(), spatial_ref)
    print(t)

    def transform(p):
        x, y, z = t.TransformPoint(p['lat'], p['lon'])
        return {'x': x, 'y': y}

    return {key: transform(p) for key, p in geo_points.items()}

points = {
    'll': {'lat': 47.483612, 'lon': 14.965127},
    'lr': {'lat': 47.483612, 'lon': 18.886929},
    'ul': {'lat': 49.559105, 'lon': 14.965127},
    'ur': {'lat': 49.559105, 'lon': 18.886929}
}

spatial_ref = osr.SpatialReference()
# PROJ is from b) and gathered from the metadatabase @ csw.eodc.eu
spatial_ref.ImportFromWkt(PROJ)

get_geog_coords(points, spatial_ref)

as a USER, I want to use different tile sizes

  • allow different tilings, other than the existing T6, T3, T1. This may be squares of 3km, 10km, 50km, 1000km, etc, and may be defined by the user
    DON'T allow tile sizes and samplings that do no divide without remainder
  • re-define standard set of tilings, which is proposed to the users, and is provided by us developers
  • perhaps: replace current definitions by shapefiles by set of rules
  • perhaps: make use of https://github.com/TUW-GEO/geospade

border break seems it's causing a weird pattern in the tile system

Hi @bbauerma,

Thank you for the amazing work on Equi7Grid.

We have been using Equi7Grid for a while and recently noticed a potential bug in the Antarctica zone. It seems there is a border break that is affecting grid generation in tiles T1, T2, and T3. This issue introduces unusual patterns, particularly in T1. Please see the attached image for reference.

image

avoid using pkg_resources to fetch version number

It seems that at the moment, 91% of the import-time for import equi7grid is due to the pkg_resources package whose only task is to identify the version number...

This performance penalty is well known for that package... I'd suggest using a different way to identify the version-number...

import pkg_resources
try:
__version__ = pkg_resources.get_distribution(__name__).version
except:
__version__ = 'unknown'

here's a quick check of the relevant import-times:

Failed to reample an image to Equi7Grid with image2equi7grid function

The image2equi7grid failed when resampling an image with non-lat/lon projectino to Equi7 Grid. It returns the below error.

====

ERROR 6: Incompatible geometry for operation
2019-10-04 15:30:42 [ERROR]: File-not-processed: S1B_EW_GRDH_1SDH_20191002T214344_20191002T214444_018302_02279D_7471.zip
Traceback (most recent call last):
File "/home/scao/shares/disk/swdvlp/git_eodc/A01-preprocessing/sgrt_A01/A01_workflow_sar_full_preprocessing.py", line 166, in A01_workflow_sar_full_preprocessing
resample_to_equi7(sar_ds, job.wflow_id,
File "/home/scao/shares/disk/swdvlp/git_eodc/A01-preprocessing/sgrt_A01/A01_workflow_sar_full_preprocessing.py", line 295, in resample_to_equi7
tiledtiff=tiled_tif, blocksize=block_size)
File "/home/scao/shares/disk/swdvlp/git_eodc/Equi7Grid/equi7grid/image2equi7grid.py", line 314, in image2equi7grid
subgrid_ids=subgrid_ids)
File "/home/scao/shares/disk/swdvlp/git_eodc/pytileproj/pytileproj/base.py", line 505, in search_tiles_in_roi
overlapped_grids = self.locate_geometry_in_subgrids(roi_geometry)
File "/home/scao/shares/disk/swdvlp/git_eodc/pytileproj/pytileproj/base.py", line 240, in locate_geometry_in_subgrids
if ptpgeometry.check_lonlat_intersection(geometry, self.subgrids.get(x).polygon_geog):
File "/home/scao/shares/disk/swdvlp/git_eodc/pytileproj/pytileproj/geometry.py", line 428, in check_lonlat_intersection
area = get_lonlat_intersection(geometry1, geometry2)
File "/home/scao/shares/disk/swdvlp/git_eodc/pytileproj/pytileproj/geometry.py", line 462, in get_lonlat_intersection
polygons = split_polygon_by_antimeridian(geometry1c)
File "/home/scao/shares/disk/swdvlp/git_eodc/pytileproj/pytileproj/geometry.py", line 489, in split_polygon_by_antimeridian
lons = [p[0] for p in in_points]
TypeError: 'NoneType' object is not iterable

NumPy deprecation warning

This issue causes a warning with Python==3.7 and numpy==1.20 at the moment:

...\lib\site-packages\equi7grid\equi7grid.py:567: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. 
When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    np.int(llx) // 100000, np.int(lly) // 100000, tilecode)

equi7grid package not working with numpy >= 1.24.0

Dear all,

np.int does not work anymore with the latest numpy version (1.24.0). See the deprecation warning below when using numpy==1.20.3.

site-packages/equi7grid/equi7grid.py:557: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. 
To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe. 
When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. 
If you wish to review your current use, check the release note link for additional information.
  Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations
    np.int(llx) // 100000,

Exception traceback when using numpy version 1.24.0

e7tile = e7grid.create_tile(e7t)
  File "/venv/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 278, in create_tile
    return self.subgrids[name[0:2]].tilesys.create_tile(name)
  File "/venv/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 505, in create_tile
    name = self._encode_tilename(llx, lly)
  File "/venv/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 596, in _encode_tilename
    return self.encode_tilename(llx, lly, self.core.sampling, self.core.tiletype, shortform=shortform)
  File "/venv/lib/python3.9/site-packages/equi7grid/equi7grid.py", line 567, in encode_tilename
    np.int(llx) // 100000, np.int(lly) // 100000, tilecode)
  File "/venv/lib/python3.9/site-packages/numpy/__init__.py", line 284, in __getattr__
    raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'int'

update static data

in the python_static_data: extents of continents are not clean polygons (update with shapes from v14)

pyproj depreciation warning for crs-specification

from equi7grid.equi7grid import Equi7Grid
grid = Equi7Grid(500).subgrids["EU"]
subgrid.xy2lonlat(3740750.0, 2554250.0)
...\lib\site-packages\pyproj\crs\crs.py:131: FutureWarning: '+init=<authority>:<code>' syntax is deprecated. '<authority>:<code>' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
  in_crs_string = _prepare_from_proj_string(in_crs_string)

mixup in doc of "tile.xy2ij" and "tile.ij2xy"

@bbauerma
there's some mixup in the documentation of the tile-functions tile.xy2ij and tile.ij2xy

  • the doc of tile.xy2ij says it returns (COLUMN, ROW)
  • the doc of tile.ij2xy says its arguments are (ROW, COLUMN)
    (I guess this is wrong...)

...if the docs would be correct, this should not be true:

from equi7grid import equi7grid
grid = equi7grid.Equi7Grid(500)
tile = grid.create_tile('EU500M_E048N012T6')
(4873500, 1233000) == tile.ij2xy(*tile.xy2ij(4873500, 1233000))
>>> True

The question of the range of decibels(dB)values

I download S1GBM_VV_mean_mosaic_v1_EQUI7_AS010M file. and take some area in china to view.
I find that the range of dB values seems not right.
As my personal understand, the SAR general situation is that the dB value should be around -5 to -17.
The distribution of results I looked at in the documentation(The normalised Sentinel-1 Global Backscatter Model, mapping Earth’s land surface with C-band microwaves.pdf) had the same distribution of values
But I noticed from the downloaded File that the dB values range around -100.
How to solve this please, thank you!
info123

Is the project alive?

Hi, I came across this project when searching for unified tiling system to be implemented in our company. In on of the pull requests, @bbauerma mentioned the team is working on a rewrite which would make the tile size more configurable. I am wondering, is the project is still alive?
Thx

fractional false eastings and northings

is there a good reason for these values being so specific? e.g. for AF

+x_0=5621452.01998 +y_0=5990638.42298

I feel like they should at least be whole integers, but also why not have clean whole chunkier numbers like 5630000 and 6000000 ? (Perhaps they are derived from some deeper grain defined in the longitude/latitude grid scheme? )

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.