Comments (3)
Turns out shapely polygons have an orient
method (thanks to @asteiker for sharing that!)
from icepyx.
Points reordering should be simple to implement with some math like this: https://stackoverflow.com/questions/51074984/sorting-according-to-clockwise-point-coordinates/51075469. I can try tonight and see if it works..
from icepyx.
I did a quick hack today,
from shapely.geometry import Point,Polygon
import numpy as np
def sort_cord_clockwise(reg_a_poly):
# this assumes that the first and last coordinate tuples are the same..
poly = Polygon(reg_a_poly)
cx,cy = [poly.centroid.xy[0][0],poly.centroid.xy[1][0]]
xy_sort = (sorted(reg_a_poly[:-1], key = lambda x: np.arctan2((x[1]-cy),(x[0]-cx))))
#this returns counterclockwise
xy_sorted = list(reversed(xy_sort[1:]))
xy_sorted.append(reg_a_poly[-1])
out_xy = [reg_a_poly[-1]]+xy_sorted
return list(out_xy)
Input: sort_cord_clockwise([(-64, 66),(-55, 72),(-55, 66),(-64, 72),(-64, 66)])
Out: [(-64, 66), (-64, 72), (-55, 72), (-55, 66), (-64, 66)]
Input: sort_cord_clockwise([(-64, 66),(-55, 66),(-64, 72),(-55, 72),(-64, 66)])
Out: (-64, 66), (-64, 72), (-55, 72), (-55, 66), (-64, 66)]
@JessicaS11, Can you check with other problematic inputs, specifically for which you got this error. You can also pass those inputs to me and I can check and refine..
from icepyx.
Related Issues (20)
- improve QUEST documentation HOT 2
- figure out where the codecov reports went HOT 2
- become PEP8 compliant HOT 1
- NSIDC request url generation currently includes duplicate keywords HOT 4
- Allow generating variables wanted from a list of h5 paths HOT 4
- Editable install instructions on contributing page could be clearer HOT 7
- remove metadata fix after next ATL{11,14,15} version up
- Add Examples Directory HOT 1
- Unable to download 5000005497555 HOT 1
- transition to Harmony API from on-prem EGI
- [harmony] transition `ipx.APIformatting` to Harmony keys
- [harmony] point granules module to Harmony instead of EGI
- [harmony] [docs] variables and subsetting
- [harmony] components of `ipx.query` likely impacted by transition from EGI HOT 1
- Add deprecation warning to icepyx v1
- Consolidate CI from Travis -> GitHub Actions HOT 2
- Move `requirements*.txt` files into `pyproject.toml` HOT 13
- Refactor setter for performance and readability
- Travis failing on fork PRs due to EDL auth error HOT 3
- Test PyPI failing due to accidental publishes from another branch HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from icepyx.