tuw-geo / equi7grid Goto Github PK
View Code? Open in Web Editor NEWDefinition of the Equi7Grid - a spatial reference optimized for global high-resolution raster data.
License: MIT License
Definition of the Equi7Grid - a spatial reference optimized for global high-resolution raster data.
License: MIT License
a) check info on tiles that cover land
https://github.com/OSGeo/PROJ/tree/9.4.0 claims to update to EPSG v11.004, which would include the EPSG codes 17771-7
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)
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.
you know what to do
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)
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.
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...
Equi7Grid/equi7grid/__init__.py
Lines 2 to 7 in c84b69b
commit code:2a9ee974159ceec5762bc637516199c73d2a4de8
Master branch v.0.0.7
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
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)
this is already addressed by the package at https://git.eodc.eu/tuwien/sar-workers/s2grid_equi7_fileconverter
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'
in the python_static_data: extents of continents are not clean polygons (update with shapes from v14)
When providing both scale and offset in image2equi7grid()
the wrong blocksize is set when calling gdal_translate
with stripped blocks. The gdal_translate
input is automatically configured with tiled blocks, whereas for the gdalwarp
call before the settings are correctly chosen.
https://github.com/TUW-GEO/Equi7Grid/blob/master/equi7grid/image2equi7grid.py#L435-L438
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)
@bbauerma
there's some mixup in the documentation of the tile-functions tile.xy2ij
and tile.ij2xy
tile.xy2ij
says it returns (COLUMN, ROW)tile.ij2xy
says its arguments are (ROW, COLUMN)...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
When resampling an image into Equi7 tiles, I would like to create a subfolder within the tile folder in order to group different type of images into different subfolders. However, this is currently not supported in image2equi7grid .
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!
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
this is already addressed in a rudimentary way by this package's module image2equi7grid.py
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? )
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.